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.

The man was being held at a London station under the Terrorism Act and on suspicion of causing grievous bodily harm. Police searches were being carried out at properties connected to him in the Luton area of Bedfordshire.

It was not clear whether the vehicle belonged to him, or whether he had travelled directly from his hometown to London. CCTV was also being analysed to see whether there was any suggestion he earlier had “scouted out” the area.

There was speculation last night that the suspect may have been a private hire taxi driver. Cabs, both traditional black cabs and private hire cars, are one of the few commercial vehicles allowed to work along the roads leading to the palace.

The Prius model is particularly popular with minicab drivers because it costs less to run and can get an exemption on the city’s Congestion Charge.

Mr Haydon said officers believe the man was acting alone and no one else was being sought by police. He added he could not speculate at this stage what the man was planning to do.

He urged the public to remain particularly vigilant during the Bank Holiday weekend when so many public events are being held. The threat from terrorism in the UK remains ‘severe’.

Luton has been linked to problems with Islamic extremism over recent years. Khalid Masood, also known as Adrian Elms, who killed five people during his attack in March on Westminster Bridge earlier this year had lived at two addresses in the town. In February, a gang were jailed for trying to persuade people to travel to Syria to join Islamic State.