A man arrested outside Buckingham Palace on Friday night was brandishing a 4ft sword as he repeatedly shouted "Allahu Akbar", police say.
Dean Haydon, head of counter-terrorism at Scotland Yard, said the man drove at a police vehicle before stopping and being confronted by three officers.
CS gas was used to "quickly" restrain the 26-year-old, from the Luton area, who is now in custody, Cdr Haydon said.
The three unarmed Westminster police officers received minor injuries.
Two of them were taken to hospital after receiving cuts to their hands and forearms.
Prime Minister Theresa May tweeted to praise the officers for acting "quickly and bravely", and Mayor of London Sadiq Khan thanked the officers for "ensuring that not a single member of the public was injured".
Counter-terror police are investigating after the man was arrested on suspicion of grievous bodily harm and assault, and under the Terrorism Act.
No members of the Royal Family were in Buckingham Palace, which is the Queen's official London residence, at the time.
The incident happened outside the Mall roundabout near Spur Road - which runs along the corner of the palace grounds - at about 20:35 BST on Friday, police said.
A man drove a blue Toyota Prius into a restricted area near the palace and "deliberately drove at a marked police vehicle and stopped in front of it", Cdr Haydon said.
When police confronted the man, he reached for a 4ft (122cm) sword in the passenger footwell of the car.
Cdr Haydon said the struggle was "quickly brought under control" and that they are treating it as an isolated incident.
"It was quickly declared a terrorist incident last night," he said.
The Met is now investigating the suspect's background and is carrying out searches in the Luton area.
Eye-witness Kiana Williamson said: "We turned up and there was one police van and one car; there was also a civilian's car that had veered towards the police car.
"They were trying to get the man out of the car, shouting; more police were arriving on to the scene and the man was fighting back.
"I saw one injured policeman with an injury to his arm, although it didn't look severe.
"He was being tended to by another officer.
"The man had been restrained and looked almost unconscious by the side of the road."
Another passer-by, who did not want to be named, said her partner initially thought he had seen a sword.
She told the Press Association: "The police didn't just run up to the car. There was some shouting prior to this; I couldn't tell you what, I was a bit panicked...
"My partner saw a sword, which I didn't see, as well as a policeman with blood on him, looking like his hand or chest was injured.
"The police officer had it in his hand, walking away with it."
A Palace spokesman said summer opening hours and tours will go ahead on Saturday, adding that it will be "business as usual".