A man has been arrested on suspicion of attempted murder after two Ministry of Defence police officers were confronted with a knife.
The incident happened at about 08:50 BST at Horse Guards Parade in Westminster, London.
A Taser was used and a 29-year-old man was restrained by officers, the Met Police said.
There were no reports of any injuries and the incident was not being treated as terror-related, the force said.
The man was also arrested on suspicion of possession of an offensive weapon and remains in custody.
Whitehall was closed for several hours due to the incident.
The 17 new ministers named did not include several relatives who had previously held portfolios, although a number of stalwarts kept their seats.
He had called on the opposition to join a unity government but they refused.
The island nation is grappling with its worst economic crisis since independence from Britain in 1948.
It is caused in part by a lack of foreign currency, which has meant that Sri Lanka cannot afford to pay for imports of staple foods and fuel, leading to acute shortages and very high prices.
With power cuts lasting half a day or more, and shortages of food, medicines and fuel, public anger has soared.
Last week, Sri Lanka also said it would temporarily default on its foreign debts. A payment on some of those bond debts was due to be made on Monday, the day on which the government is to begin bailout talks with the International Monetary Fund.
The stock exchange has also been suspended for a week with effect from Monday.
Mass protests began in early April with people calling for President Rajapaksa to quit. His cabinet resigned en masse but he refused to go, despite the opposition arguing that he had lost the people’s mandate.
His appointment of a new cabinet appears to be another sign that he will not bend to protesters’ demands.
It also comes hours after some media outlets sympathetic to his government labelled peaceful protests in the capital “a beach party”, and implied that they were funded by terror organisations. The protests in Colombo’s Galle Face Green have attracted thousands of people.
When the protests broke out, Mr Rajapaksa activated a draconian emergency law and imposed a curfew to try to stop them. He also banned social media.
He later withdrew these measures when they failed to deter protesters.
Both he and his elder brother, Prime Minister Mahinda Rajapaksa, who was not among those who resigned and who keeps his post in the new cabinet, have addressed the nation in an apparent attempt to placate protesters. But calls for the president to resign have only grown louder.
The demonstrations mark a massive turnaround in popularity for Mr Rajapaksa who swept into power with a thumping majority win in 2019, promising stability and a “strong hand” to rule the country.
Critics say rank corruption and nepotism – his brothers and nephews occupied several key ministerial portfolios – are the main reasons for the situation the country has found itself in.