WASHINGTON — President Donald Trump pledged in his campaign that he would not be predictable. He's more than lived up to that promise this week, and along the way, he has made a hash out of the way business is being done in Washington.

Three times this week, Trump abruptly and unexpectedly changed course, lending credence to perceptions of a presidency in chaos. The biggest bombshell came Thursday afternoon, when Trump announced that Defense Secretary Jim Mattis would leave the administration at the end of February, and Mattis's resignation letter explicitly stated that he and the president were not in alignment on major policy issues or on America's role in the world.

The Mattis news rattled nerves in Washington and no doubt in capitals around the world. It came at the end of another roller coaster day in the history of a presidency that has had many of them. The day began with Trump, for the second time in a week, reversing course on funding for a border wall. He demanded that Congress include funds for the wall, just as a compromise bill without the money he wants was making its way through Congress in an effort to avert a government shutdown this weekend.

He can change his mind at any moment.

Trump's allies were already reeling from the announcement via tweet on Wednesday that he was ordering the withdrawal of U.S. troops from Syria. On this announcement, there was no warning to U.S. allies or to members of Congress, including many in his party who opposed the move — no warning even to some in his administration.

Trump is, by his own words, a dealmaker without peer, but his volatility overwhelms his reliability. He demonstrated anew this week that he can change his mind at any moment. Those around him are left to adapt, to pick up the pieces, to explain as best they can — including those whose advice he has spurned or whose words have been shredded by his actions. In this case, it appeared to have cost him the services of his defense secretary.

Give the president some credit. His goals remain fixed. He wants a wall on the U.S.-Mexico border, or at least he wants the issue of demanding one to use against Democrats, who oppose the wall.

He wants the most robust military in the world, but he doesn't seem to want to use it. He has been consistent in questioning the commitment of U.S. forces in trouble spots such as Syria and Afghanistan. On national security policy, he remains a rhetorically muscular noninterventionist. With the announcement on Syria, the focus quickly shifted to the question of whether he would order a rapid drawdown of U.S. forces in Afghanistan.

However consistent he has been in enunciating goals, though, he has not shown much mastery of navigating the legislative process or of developing support from allies for his foreign policy objectives. He leads by impulse, by upending the status quo, leaving friends and adversaries to scramble.

U.S. soldiers in northern Syria in March 2017 — Photo: Lance Corporal Zachery Laning, U.S. Marine Corps

This is not an entirely unsuccessful approach. His trade policies, for example, have roiled relationships, but he has gotten the attention of China, whose policies have been criticized by past presidents and leaders in other nations for years. For that, other nations are no doubt grateful, even if no one is certain how the ongoing dispute will be resolved or when. On Thursday, he signed a new farm bill, and he will soon be able to sign a criminal justice reform bill that was approved with overwhelming, bipartisan support.

But the turmoil that goes along with those successes has badly strained the system, and these past few days have highlighted that reality once again. The path he has followed in pursuit of $5 billion in funding for a border wall in the latest spending bill is emblematic of his unorthodox — some would call it destructive — governing style.

He staged an Oval Office argument with House Speaker-designate Nancy Pelosi, D-Calif., and Senate Minority Leader Charles Schumer, D-N.Y. He was told he didn't have the votes for the $5 billion he wanted. He said he would take a shutdown rather than a walk back.

Alarmed Republican allies in Congress, who wanted no part of a shutdown if possible, began pressing for a way out, and earlier in the week, it appeared they had gotten the attention of the White House when the announcement came that it would look for other ways to fund the wall. Meanwhile, the president continued the fiction that taxpayers would not be paying for the wall. Not even the fuzziest of math could make that explanation credible.

Congressional leaders were put in a near-impossible position.

Trump's retreat early in the week was enough to get Congress to move toward an agreement on a short-term bill to keep the government open until after the new year, without the $5 billion Trump was demanding.

Few Republican members of Congress wanted to make this fight at this moment, against united Democratic opposition. But the storyline of the funding fight included the claim that Trump had once again caved on a central promise of his candidacy, that he had blustered and then backed down.

On Thursday morning, the dam broke at the White House, and congressional leaders were put in a near-impossible position to find a solution. Congress has until Friday night to find a new way to avoid a government shutdown. The president said he would shoulder the blame if the shutdown occurs. What lawmakers would probably appreciate more than that is for the president to become part of the solution, rather than adding to the problems they already have.

The president's explanation for the decision to withdraw troops from Syria went through a series of rewritings. Trump's initial tweet stated that the Islamic State, also known as ISIS, had been defeated in Syria and that that was why the troops could come home. "We have won against ISIS," he said in a White House video. "We've beaten them, and we've beaten them badly. We've taken back the land, and now it's time for our troops to come back home."

In doing so, he ignored statements over months from others in his administration that offered contrary analysis and commitments. While the Islamic State has suffered significant losses of territory in Syria, other administration officials say, it has not been defeated. Beyond that, administration officials had vowed to keep U.S. forces there as long as necessary, to counter Iranian influence and activity.

By Thursday, Trump had moved to a different explanation, one that no doubt comes closer to his true feelings. He asked, "Does the USA want to be the Policeman of the Middle East ... Do we want to be there forever? Time for others to finally fight."

He said — despite contrary evidence — that Russia, Iran and Syria were unhappy because they now would have to fight the Islamic State alone, which only a day earlier he had claimed had been defeated. Then, in one more burst, he added, "I am building by far the most powerful military in the world. ISIS hits us they are doomed!"

Mattis made clear in his resignation letter that he and the president do not see eye to eye on rising threats from Russia and China or on the importance of maintaining "the solidarity of our alliances." His departure will leave a sizable void in the administration's national security apparatus and, more significantly, point to the potential for more chaos in the months ahead.

See more from Opinion / Analysis here