House Speaker Nancy Pelosi has cancelled plans to travel on a commercial airline to visit US troops in Afghanistan after accusing Donald Trump of causing a security risk by talking about the trip.

It was the latest twist in the game of brinkmanship between Ms Pelosi and Mr Trump, playing out against the stalled negotiations over how to end the partial government shutdown.

Earlier in the week, Ms Pelosi had asked Mr Trump to reschedule his January 29 State of the Union address, citing security issues at a time when the Homeland Security Department and other agencies remain unfunded.

Mr Trump responded by cancelling the military plane that was to have carried Ms Pelosi and a congressional delegation to Afghanistan on the previously undisclosed visit. Mr Trump suggested she travel by commercial plane instead.

Mr Trump had belittled the trip as a “public relations event” — even though he had just made a similar war zone stop — and said it would be best if Ms Pelosi remained in Washington to negotiate to reopen the government.

“Obviously, if you would like to make your journey by flying commercial, that would certainly be your prerogative,” wrote Mr Trump, who had been smarting since Ms Pelosi called on him to postpone the State of the Union address.

On Friday, Ms Pelosi announced that her plan to travel by commercial plane had been “leaked” by the White House.

Spokesman Drew Hammill said Ms Pelosi and accompanying lawmakers were prepared to take a commercial flight but cancelled after the State Department warned that publicity over the visit had “significantly increased the danger to the delegation and to the troops, security, and other officials supporting the trip”.

The political tit-for-tat laid bare how the government-wide crisis has devolved into an intensely pointed clash between two leaders determined to prevail.

It took place as hundreds of thousands of federal workers go without pay and Washington’s routine protocols — a president’s speech to Congress, a lawmaker’s official trip — become collateral damage.

Denying military aircraft to a senior lawmaker — let alone the speaker, who is second in line to the presidency after the vice president — is very rare.

Mr Hammill said the speaker planned to travel to Afghanistan and Brussels to thank service members and obtain briefings on national security and intelligence “from those on the front lines”.

He noted Mr Trump had travelled to Iraq during the shutdown, which began on December 22, and said a Republican-led congressional trip had also taken place.

Mr Trump’s trip to Iraq after Christmas was not disclosed in advance for security reasons.

Democrat Adam Schiff of California slammed Mr Trump for revealing the travel plans.

“I think the president’s decision to disclose a trip the speaker’s making to a war zone was completely and utterly irresponsible in every way,” Mr Schiff said.

Some Republicans also expressed frustration.

Senator Lindsey Graham tweeted: “One sophomoric response does not deserve another.” He called Ms Pelosi’s State of the Union move “very irresponsible and blatantly political” but said Mr Trump’s reaction was “also inappropriate”.