Senate Republicans narrowly defeated an amendment Friday that would have limited President Donald Trump’s ability to attack Iran without congressional approval. The 50-40 vote gave the measure a majority of votes cast, but due to parliamentary maneuvering by Senate leadership, it needed 60 votes to pass.

The measure was intended as a rebuke of Trump’s threats and escalatory policy toward Iran and drew four Republican votes. Trump has publicly threatened Iran with “obliteration” and said he doesn’t need congressional approval for military strikes on the country.

The measure was proposed by Sens. Tom Udall, D.-N.M. and Tim Kaine, D-Va., as an amendment to an annual defense funding bill. Udall stated that the bipartisan support for the amendment “sent a powerful and resounding message: Congress is not going to roll over for an unconstitutional war. President Trump and his advisors should heed this significant vote [and] change course from the saber-rattling and reckless escalation.”

The amendment and a related bill proposed by Udall are rare attempts by Congress to use its most significant power — the power of the purse — to prevent the executive branch from waging war with a specific country before that war begins. Even the most significant restriction on presidential war-making since World War II, the 1973 War Powers Act, simply stated that the president “shall terminate” hostilities after 60 days if they have not been authorized by Congress, rather than prohibiting the spending of appropriated funds to wage such wars.

If the amendment had passed, it would have prohibited the Pentagon from using any funding to attack Iran without congressional authorization. Senate Majority Leader Mitch McConnell, R-Ky., said the measure would “hamstring” Trump.

McConnell was largely responsible for the amendment’s defeat. Democratic and Republican Senate aides told The Intercept that under McConnell’s direction, the Senate parliamentarian ruled the measure “not germane” to the substance of the bill, thus requiring it to get 60 votes to pass instead of a simple majority.

Last week, the New York Times reported that Trump’s advisors persuaded him to authorize military strikes on Iran in retaliation for the Iranians shooting down an unmanned American reconnaissance drone, but the strikes were called off at the last minute.

The effort to pass the amendment came amid longstanding concerns that the Trump administration has been trying to lay the legal ground for attacking Iran without congressional authorization, and that such an attack could escalate into a full-scale war before Congress weighed in.

The Times also reported last month that Mike Pompeo, Trump’s hawkish secretary of state, has been trying to convince a skeptical Congress that Iran has ties to Al Qaeda dating back to the days after the 9/11 attacks. Members of Congress have expressed alarm that such a claim could serve as the basis for using the 2001 Authorization for Use of Military Force, passed three days after the 9/11 attacks, to justify attacking Iran.

The Trump administration’s actions worried Democrats so much that they threatened to block the Pentagon spending package if they didn’t get an up or down vote on the amendment, Democratic and Republican aides told The Intercept. Democratic leader Chuck Schumer and Senate Majority Leader McConnell reached a deal to hold a vote Friday in order to give Democratic presidential candidates time to return from the debates.

The amendment was opposed by the Trump administration and most Republicans, who argued that it would limit the administration’s ability to retaliate against potential Iranian provocations in real time.

In a letter sent to the Senate Armed Services Committee Wednesday and obtained by The Intercept, Undersecretary of Defense for Policy John Rood argued that the amendment would “limit the President’s authority in discharging his responsibility as commander in chief” and said that it “could embolden Iran to further provocations.”

Udall and Kaine’s amendment was not the only one offered to address the current situation in the Persian Gulf. Republican Sen. Mitt Romney of Utah introduced an amendment earlier this week to counter Udall’s, which clarified that DOD could use funds in the spending package to “defend themselves, and United States citizens, against an attack by the government, military forces, or proxies of a foreign nation or by other hostile forces.”

In a floor speech Thursday, Romney said that his amendment was not intended to authorize military force “against Iran or anyone else” but was instead a “statement of continued commitment to our national defense.” Legal commentators nonetheless wondered if it could be cited as a form of congressional approval for a retaliatory attack.

Senate leadership found Romney’s amendment germane, so it only needed a simple majority and passed by a vote of 90-4. All four nay votes came from Democrats: Vermont’s Pat Leahy, Tammy Duckworth of Illinois, Mazie Hirono of Hawaii, and New Jersey’s Cory Booker. McConnell’s office did not respond to requests to comment on why Romney’s amendment was found germane while Udall’s was not.