The measure passed the Senate, 77 to 23, and now goes to the House.

The bill has several parts, some controversial and some not, and the senators voting no were not necessarily doing so solely because of troop withdrawals. Mr. Brown, for instance, said he was concerned about the constitutionality of the bill’s other contentious provision, which would let state and local governments punish companies that boycott Israeli products.

Why it matters

For almost 15 years, since the Iraq war became an unpopular drag on President George W. Bush, Democrats have generally opposed extended military interventions in other nations. So it’s not surprising that most of the 2020 candidates would want to bring troops home from Afghanistan and Syria sooner rather than later.

The twist is that this is a rare issue on which, ideologically, Mr. Trump is more aligned with Democrats than Republicans — which creates an awkward political situation for the Democrats, who would not normally decline an opportunity to rebuke Mr. Trump.

But even under previous presidents, foreign policy has split Democrats, often painfully.

John Kerry famously had to walk that tightrope as the party’s presidential nominee in 2004, when an increasingly antiwar electorate denounced his previous support for the Iraq war. At one point, he said of a supplemental appropriation for the war, “I actually did vote for the $87 billion before I voted against it,” a line that allowed opponents to brand him as a “flip-flopper” and haunted him for the rest of the campaign.

Tuesday’s vote underscored how politically fraught issues of military force and funding still are, especially as the liberal wing of the Democratic Party gains strength.