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.