President Trump, a foreign-policy neophyte increasingly emboldened to chart his own course, grew testy with the members of his national-security team when they huddled in the White House Situation Room on Tuesday to debate Syria. The split had been publicly telegraphed just hours earlier. At the U.S. Institute of Peace, I listened to top U.S. officials—one running the military campaign against ISIS and the other coördinating the international coalition—stress the need for American forces to stay in Syria.

“We are in Syria to fight ISIS. That is our mission, and our mission isn’t over,” Brett McGurk, the State Department coördinator for the international coalition fighting ISIS, told the audience. Two pockets of ISIS fighters—numbering in the low thousands—remain in the eastern Euphrates Valley and along the border with Iraq. Among them is the ISIS leader, Abu Bakr al-Baghdadi. “We have to work through some very difficult issues as we speak,” he said. “We are going to complete that mission.”

About two thousand U.S. troops are still deployed in Syria, largely in the northeast, where they aid and advise local militias that have forced ISIS out of almost a third of Syria, including the Islamic State’s nominal capital, in Raqqa. However, the trickier part of the military campaign—stabilizing liberated areas, so that ISIS does not return—still lies ahead.

“The hard part, I think, is in front of us, and that is stabilizing these areas, consolidating our gains, getting people back into their homes,” General Joseph L. Votel, who heads Central Command operations, candidly told the conference. “There is a military role in this, certainly in the stabilization phase.”

Even as the panel was still speaking, Trump was holding a press conference, a few blocks away, with the Presidents of the three Baltic states. He was visibly angry when asked about Syria. “I want to get out,” he said, his voice rising. “I want to bring our troops back home. I want to start rebuilding our nation. We will have, as of three months ago, spent seven trillion dollars in the Middle East over the last seventeen years. We get nothing—nothing out of it, nothing.” He called it “a horrible thing.”

“So it’s time,” Trump said. “We were very successful against ISIS. We’ll be successful against anybody militarily. But sometimes it’s time to come back home.”

Every Administration has had deep internal rifts; every President wants to get the troops home as soon as possible. But the total disconnect—so highly public—between the President and his top advisers on strategy to confront a major threat to national security stunned Washington. Just this week, U.S. troops were reportedly building new frontline positions and bringing more equipment, including construction material, into Syria to improve their capabilities.

Trump made the same argument when the National Security Council met later that afternoon. The President was still cranky. With the recent firing of both his Secretary of State and national-security adviser—and with their successors not yet in place—the generals took the lead. James Mattis, the Defense Secretary; General Joseph Dunford, the chairman of the Joint Chiefs of Staff; and Votel tried to persuade Trump to stay the course in Syria for another year or two. They argued that if the area under control of U.S.-backed forces—in almost a quarter of the country—is not stabilized, ISIS could make a comeback. Stabilization involves everything from turning water and electricity back on to clearing thousands of deadly mines and fostering local governance councils—steps allowing the return of life to war-ravaged areas. The failure to fully stabilize Iraq before the U.S. pulled out in 2011—notably brokering a power-sharing agreement among rival communities—contributed to political alienation and the rise of ISIS there.

Trump’s advisers also argued that withdrawal could diminish the U.S.-led coalition’s leverage in a political settlement to end the war. It could lessen pressure on President Bashar al-Assad—whose ruthless response to peaceful protests sparked a war that has killed half a million people and left more than half of the country’s twenty-two million residents displaced—to make concessions. The State Department issued a scathing condemnation of the Assad regime on Wednesday, the first anniversary of Syria’s chemical-weapons attack on civilians in Khan Sheikhoun, which killed or injured hundreds of men, women, and children. A year after Trump launched a cruise-missile strike in response to the chemical attack and declared that “no child of God should ever suffer such horror,” the State Department said, “There has been no let-up in the atrocities committed by the Syrian regime, enabled by its backers, in flagrant violation of international law.”

Yet Trump, in the White House meeting, dismissed argument after argument about a longer timetable to finish the mission in Syria. A premature withdrawal, Trump’s advisers posited, would also take the United States out of the game in a country that is the geostrategic center of the Middle East—and borders five countries allied with the U.S.

The generals warned that an already complex war in Syria, now beginning its eighth year, would get even more complicated. They cited the dangers of the Assad regime or other foreign powers—including Iran and its allies in Hezbollah—filling the vacuum in areas that U.S. troops have worked so hard to help liberate. Without the constant threat of U.S. airpower, Russia could feel emboldened to operate in a broader swath of territory. Turkey recently intervened in northern Syria in a campaign targeting U.S. allies—drawing them away from the war against ISIS. A decision to pull out could also strand the Kurds, whose forces have fought most fiercely against ISIS in Syria.

Trump was unconvinced by—and impatient with—the advice, sources familiar with the debate told me. More than once he said, “Why do I have to be the one to do this?” one told me.

Trump’s Republican allies in Congress have warned him against premature withdrawal. “It’d be the single worst decision the President could make,” Senator Lindsey Graham, a South Carolina Republican and member of the Senate Armed Services Committee, told Fox News on Sunday. “We got ISIL on the ropes. You want to let ’em off the ropes, remove American soldiers,” Graham said, using another term for the Islamic State. “This is a disaster in the making,” he said. “There are over three thousand ISIS fighters still roaming around Syria. If we withdrew our troops anytime soon, ISIS would come back, the war between Turkey and the Kurds would get out of hand, and you’d be giving Damascus to the Iranians without an American presence.”

In recent days, Middle East allies—including Israel, Saudi Arabia, and even Turkey—have also cautioned the President against withdrawing precipitously from Syria, diplomats told me. The appeals seemed only to further irritate Trump. Just hours earlier, he had referred publicly to his recent conversation with King Salman of Saudi Arabia. “Well, you know, you want us to stay—maybe you’re going to have to pay,” Trump said, at the press conference.

The President’s calculation sometimes seemed to be exactly that—transactional, or from a ledger. At one point, he said that the United States should not be building bridges in Raqqa when it wasn’t building them in Wisconsin, the well-placed source told me. No argument changed his mind.