The man arrested outside Buckingham Palace drove at police before lunging for a 4ft sword and repeatedly shouting “Allahu Akbar”.
The 26-year-old man from Luton was wrestled to the ground by unarmed police who had to use CS gas to incapacitate him.
During the struggle three officers were injured, two of whom suffered minor cuts to their hands and required treatment in hospital before being discharged.
The three policemen were praised for their bravery and speed in containing the situation.
The Prime Minister, Theresa May, tweeted: “I want to thank the officers who acted quickly and bravely to protect the public last night, demonstrating the dedication and professionalism of our police.”
The attack happened shortly after 8.30pm on Friday when The Mall, Constitution Hill and Birdcage Walk, the roads running through St James’s Park and Green Park towards the palace, were still full of tourists.
The motorist was said to have driven a Toyota Prius at a police van on a restricted part of road directly opposite the palace.
The car pulled up abruptly in front of the van and as officers emerged he grabbed into the passenger footwell and produced a 4ft sword.
The police eventually overcame the man who had been alone in the car. Passersby said they saw the motorist, who may have been driving on the wrong side of the road at one point, being restrained by officers on the ground. Some said he appeared to have a machete.
Commander Dean Haydon, of the Met’s counter-terrorism branch, said: “A blue Toyota Prius deliberately drove at a marked police vehicle and stopped in front of it.
“Uniformed officers then confronted the driver of the vehicle and during that confrontation the driver reached for a four-foot sword that was in the passenger footwell.
“CS gas was used as part of the arrest and during the struggle the individual repeatedly shouted the words Allahu Akbar.”
He praised the “bravery and professionalism” of the officers, adding that: “Their vigilance, courage and the swiftness of their response demonstrates how our officers are protecting the public.”