During his presidential campaign, Donald Trump ran on a foreign policy platform that emphasized an “America first” approach. He sounded almost isolationist at times in his insistence that the country would not rush to war and would seek to avoid entanglements in defense and trade. At several points, he spoke out against the idea of intervening in Syria, specifically. But it took less than three months in office for Trump to change directions and get involved in Syria.

Trump is hardly the first president to campaign on peace and govern in war. Barack Obama in 2008 didn’t campaign as an isolationist, but he won the Democratic nomination in part on the strength of his opposition to the Iraq war, and he pledged to avoid “dumb wars” and to seek international partnerships. As president, however, Obama drew criticism from the left and right for being slow to wind down the wars in Iraq and Afghanistan, for relying heavily on drone strikes and special operations (often without explicit congressional approval), and for ordering airstrikes in Libya in 2011. George W. Bush campaigned on a less interventionist foreign policy, advocating for fewer nation-building efforts and bringing troops back from the Balkans; history, of course, turned out very differently. In 1964, Lyndon Johnson ran on a promise not to expand the conflict in Vietnam and then did just that. Perhaps the starkest historical example is Woodrow Wilson’s 1916 re-election campaign slogan: “He kept us out of the war.” In 1917, the United States declared war on Germany and joined World War I. Intervening events, most notably in the case of Bush and 9/11, have driven some of these changes. But there are other forces — both political and practical — at work.

For one thing, presidents often learn that foreign policy looks more complicated from the Situation Room than on the campaign trail. There are few costs to candidates for talking about avoiding or getting out of unpopular conflicts. Actually standing back in the face of a civil war, humanitarian crisis or other forms of violence — especially in a sensitive region of the world — is much harder. Deciding not to intervene can also have consequences. Bill Clinton chose not to use U.S. military power to stop Rwandan genocide early in his first term; he later came to view that decision as a mistake, and political pressure to act against human rights abuses informed his response to later violence in the Balkans.

Presidents may also be more likely to change their tune on foreign policy than on domestic affairs because partisan politics provide less of a framework. In recent years, Democrats have tended to take a more dovish stance while Republicans have been more hawkish. However, these lines are not definitive — liberals and conservatives alike can find ideological justifications for either intervening in a foreign crisis or for staying out of it. Interventionists on the left can cite human rights justifications. Isolationist Republicans can draw on nationalism, as expressed in Trump’s “America First” slogan, and concern about the strain that war places on public finances. These ideological scramblings aren’t new; isolationist and interventionist strains have historically been present in both parties.

The result is a long history of presidents clashing with elements of their own parties on foreign policy. Wilson’s decision to join World War I led to the resignation of his secretary of state, fellow Democrat William Jennings Bryan. Foreign intervention was one of the points of contention between Eisenhower and Robert Taft in the battle for the 1952 Republican nomination; later, when Eisenhower was president, some Senate Republicans pushed a constitutional amendment to limit presidential treaty-making power. More recently, there have been notable splits within parties over foreign policy, sometimes dividing a relatively hawkish party establishment from more reticent voters and activists. This tension defined the historic rift in the Democratic Party over the Vietnam War in 1968.

Partisan politics still matters, of course. Many Democrats protested the war in Iraq when Bush was in office but fell silent once a member of their own party was in office. Congressional Republicans, meanwhile, resisted Obama’s request for an Authorization for Use of Military Force in Syria in 2013, but are now poised to support Trump if he makes a similar request. All of this adds up to some complex party dynamics: Like most things in American politics, attitudes about foreign policy can split along party lines, with Republicans usually favoring military action more than Democrats do. But both parties encompass a range of views, and the party identification of the president seems to matter almost as much as the substance of the policy.

The backdrop for all of this is that in recent decades, presidents have been relatively unconstrained by Congress when it comes to military action. The Constitution gives Congress the power to declare war, but presidents have increasingly accumulated the power to initiate military interventions. Sometimes Congress grants authorization but not always. In practice, presidents have a great deal of flexibility to decide where the military will intervene and in what capacity. Compared with an ambitious domestic plan — such as health care or tax reform, say — it’s much easier for presidents to direct foreign policy.

While presidents enjoy a great deal of leeway in the short term, however, the long term is another story. Sustaining a prolonged military engagement requires support in Congress and, ultimately, the electorate. If Trump’s actions turn into longer-term involvement in Syria, the country will need to pay for these interventions, and Congress ultimately holds the purse strings. Lingering military involvement can drag down a president’s esteem with the public, as Johnson found out with Vietnam and Bush found out with Iraq. Democrats, already eyeing the 2018 midterm elections, could try to go back to some of the anti-war appeals of the 2006 and 2008 campaigns.

Trump also leads a generally hawkish party, but his own campaign promises rested on the idea that he wasn’t a typical Republican. The evidence is mixed as to whether his core supporters in the Republican coalition are likely to support foreign interventions. FiveThirtyEight’s Dan Hopkins noted last spring that Trump supporters were less likely to support staying in Iraq than Rubio or Cruz voters but were more hawkish overall. A YouGov poll found that Republicans in general, but especially Trump voters, were more likely than others to cite terrorism as a top concern. Linking military action to the prevention of terrorism might persuade those voters to support longer-term involvement. Recent history suggests, however, that voters sour on military action the longer it continues. If Trump pursues this course in Syria, it will likely open up opportunities for other candidates to enter the 2020 field with promises to end the fighting.