Names under consideration to replace Jim Mattis as US defense secretary are “not all military”, a leading Trump ally said, as the president pushed the retired marine general out of the White House door.

Mattis resigned this week but Trump brought forward his departure, piqued by a resignation letter which was strongly if implicitly critical of the president, particularly over his treatment of US allies, and which attracted favourable media coverage. The deputy defense secretary, Patrick Shanahan, will take over as acting secretary.

On Monday morning, Trump tweeted that Mattis “did not see as a problem” one of the president’s bugbears: the cost of alliances with countries which supposedly “take total advantage of” American taxpayers. He also attacked the US envoy to the coalition fighting Islamic State, Brett McGurk, who also resigned.

Mattis’s removal came amid a government shutdown and as the Washington Post and New York Times published reports on a White House in meltdown. Trump was depicted calling advisers “fucking idiots” and complaining that so much of Washington and the media is against him, he faces “a war every day”.

Trump now needs a new face to run America’s everyday wars. Mattis and McGurk resigned after the president abruptly decided to withdraw 2,000 troops from Syria, seemingly at the behest of Turkey, which is openly hostile to America’s Kurdish allies. News of a planned withdrawal of half the 14,000 troops in Afghanistan followed.

In keeping with dismissals including that of the former secretary of state, Rex Tillerson, Trump did not give Mattis the news. The secretary of state, Mike Pompeo, notified him, an anonymous official told the Associated Press.

The sudden change stripped Mattis of any chance to smooth relations with rattled allies. Domestically, White House staff sought to limit the damage, one official telling the AP Trump simply decided to avoid a drawn-out transition. Trump’s acting chief of staff, Mick Mulvaney, told ABC the president and Mattis “did not share some of the same philosophies”.

I’m just saddened for our country. I’m saddened for the broken relationships with countries that have been with us Bob Corker

Evidence for the claim was readily available. In September, Trump told CBS Mattis was “sort of a Democrat”, adding: “But General Mattis is a good guy. We get along very well. He may leave.”

On Saturday, Trump tweeted: “When President Obama ingloriously fired Jim Mattis, I gave him a second chance. Some thought I shouldn’t, I thought I should. Interesting relationship.” Regarding Mattis’s criticism, the president added: “Allies are very important – but not when they take advantage of US.”

Mulvaney said the president and Mattis “just could never get on the same page” on Syria, and added that Trump had said since his campaign that “he wanted to get out”. The president, Mulvaney said, was “entitled to have a secretary of defense committed to that same end”.

Mattis was widely seen as one of Trump’s last “adults in the room”, able to resist the president’s wilder impulses, as reported by Bob Woodward in his book Fear. Mattis denied saying Trump had the understanding of a child or blocking a mooted assassination of the Syrian president, Bashar al-Assad. Fear remains a bestseller.

Mulvaney said he had “encouraged [Trump] to find people who have some overlap with him but don’t see the world in lockstep with him.”

Play Video 1:30 Trump: Saudi Arabia decision about 'America first' – video

Shanahan was a senior vice-president at Boeing when he became Pentagon deputy in July 2017. A White House official said Trump wants to focus on streamlining purchases, on which Shanahan has been working.

Jim Mattis's resignation letter to Donald Trump – in full Read more

During a lunch with conservatives on Saturday, Trump discussed a replacement. They were “not all military”, said Senator Lindsey Graham of South Carolina, a military veteran and foreign policy hawk whose name crops up on lists of possible defense picks. Another hawkish senator and veteran, Tom Cotton of Arkansas, is also regularly mentioned.

However, Trump’s Syria decision prompted Republican opposition. The Senate majority leader, Mitch McConnell, urged him to reconsider “a premature and costly mistake” while on Sunday Bob Corker, chair of the Senate foreign relations committee, told CNN he was “saddened for our country”.

“I’m saddened for the broken relationships with countries that have been with us,” he said. “I’m saddened for the many Kurds and others who will likely be killed and slaughtered by either the Syrians or the Turks. I’m saddened for our country in being so unreliable.”

Trump answered on Monday, on Twitter: “We are substantially subsidizing the Militaries of many VERY rich countries all over the world, while at the same time these countries take total advantage of the US, and our TAXPAYERS, on Trade. General Mattis did not see this as a problem. I DO, and it is being fixed!”

He also claimed McGurk, who on Saturday he said he did not know, “was the Obama appointee who was responsible for loading up airplanes with $1.8bn in CASH & sending it to Iran as part of the horrific Iran Nuclear Deal (now terminated) approved by Little Bob Corker”.

Trump regularly repeats inaccurate claims about payments to Iran. According to the website Politifact, the $1.8bn figure is a slight exaggeration of a transfer that covered an order for military equipment made before the 1979 revolution and thus never fulfilled. The attack on McGurk echoed remarks by Mulvaney and other aides. He was appointed as Isis envoy by Barack Obama in 2015 but his first senior jobs as a diplomat, on Iran and Iraq, were under George W Bush.

Senators asked Trump to withhold a final decision on Syria for 90 days. But on Monday the Pentagon confirmed that Mattis had signed the withdrawal order. No operational details were provided.

On Sunday, Trump tweeted: “President Erdoğan of Turkey has very strongly informed me that he will eradicate whatever is left of Isis in Syria … and he is a man who can do it plus, Turkey is right ‘next door’. Our troops are coming home!”

In Syria, Turkish troops were reported to be concentrating near Manbij, a town held by Kurdish fighters.