The House approved a measure Friday that would bar President Donald Trump from launching a military strike against Iran, setting up a confrontation with the White House over the administration’s aggressive stance toward Tehran.

The House proposal – which was added to a sweeping $733 billion defense bill by a vote of 251-to-170 – would bar the Trump administration from using any federal funds for military force “in or against” the Islamic Republic, unless the president receives explicit congressional approval for a strike. It would not bar the president from responding to an attack on the U.S.

The underlying annual defense bill, passed on Friday by a vote of 220-to-197, also includes several other contentious provisions. It would, for example, reverse Trump’s ban on transgender personnel serving in the military and enact a one-year ban on the sale of air-to-ground munitions to Saudi Arabia and the United Arab Emirates for use in the Yemen war. The Trump administration has pushed to bypass Congress in selling weapons to the Saudis and the UAE, sparking a bipartisan backlash.

But the Iran provision was the most noteworthy, with 27 Republicans bucking the White House to support the measure. Trump nearly bombed Iran last month after Tehran shot down a U.S. military surveillance drone. Although the president called off the strike at the last minute, he has since threatened Iran with “obliteration” and warned that the U.S. would use “overwhelming force” if it attacked American assets or personnel.

Speaking to reporters on Friday, Trump said Iran was treading on very dangerous territory. “Iran if you’re listening, you better be careful,” the president said.

Democrats say a war with Iran would be a prolonged and disastrous conflict – precisely the kind of “endless war” that Trump campaigned against in 2016. Some Republicans also fear that another war in the Middle East would be a terrible mistake, and there’s bipartisan concern that Congress has ceded too much of its war powers to the president in recent years.

“This is the only way to stop Trump from starting another costly war,” said Rep. Ro Khanna, a California Democrat and a lead sponsor of the measure. “This is how we democratize our foreign policy and put an end to unconstitutional wars.”

He authored the amendment with Florida Republican Matt Gaetz, who hailed its passage as in line with Trump’s pledge to avoid far-flung military conflicts.

“The Gaetz-Khanna amendment affirms what President Trump knows and believes: unfocused, unconstitutional, unending wars in the Middle East make America weaker, not stronger,” Gaetz said Friday. “The time has come for Congress to once again reassert its constitutional authority and speak decisively on matters of war and peace.”

The GOP-held Senate rejected a similar proposal last month as that chamber debated its defense authorization bill, which would authorize $750 billion for Pentagon programs in the next fiscal year. Many Republicans warned that restricting Trump’s military options would be a dangerous step at a time when Iran has allegedly threatened U.S. assets in the region.

“Bottom line, this amendment will give comfort to our enemy, who has the blood of Americans on their hands — from the Marine barracks bombing to the Iraq War — and who continues to hold American hostages to this day,” Rep. Michael McCaul, R-Tx., the top Republican on the House Foreign Affairs Committee, said during the House debate.

The Iran vote came a day after the House approved another limit on Trump’s foreign policy: an amendment that would force the administration to end U.S. military support for Saudi Arabia’s military operations in Yemen.

The twin legislative actions represent a new level of congressional push back against Trump’s foreign policy, as Democrats use their House majority to rebuke the president over his aggressive stance toward Iran and his cozy ties with Saudi Arabia.

Trump has already vetoed a stand-alone bill to end the U.S. role in Yemen. He argued it was “an unnecessary, dangerous attempt” to weaken his constitutional power.

Republicans in Congress have also said that limiting U.S. involvement in Yemen would give Iran a green light to spread its influence across the region. The civil war in Yemen is essentially a proxy battle between Saudi Arabia and Iran, which is backing Houthi rebels who overthrew Yemen’s government more than four years ago.