The US Congress on Wednesday gave its final approval to a bid to restrain President Donald Trump from attacking Iran, a sign of lawmakers’ alarm after soaring tensions.

A month after the resolution cleared the key hurdle of the Senate, which is controlled by Trump’s Republican Party, the Democratic-led House of Representatives voted 227-186 to approve the measure that bars any military action against Iran without an explicit vote from Congress.

But the resolution is virtually certain to be vetoed by Trump, and the coalition of most Democrats and a handful of war-sceptic Republicans lacks the votes to override him.

“If President Trump is serious about his promise to stop endless wars, he will sign this resolution into law,” said Senator Tim Kaine, the Democrat who spearheaded the move.

The House voted moments after a rocket fired on a military base north of Baghdad killed an American soldier, a British soldier and a US contractor, in the deadliest such attack on foreign forces in Iraq in several years.

A similar attack in December that killed a US contractor set off a chain of escalation after the US blamed it on Iranian-aligned Iraqi Shiite militias.

On January 3, Trump ordered a drone strike that killed Iran’s most powerful general, Qassem Soleimani, at the Baghdad airport.

Supporters of the resolution said they wanted to ensure that Congress has the unique power to declare war, as outlined in the US Constitution.

“There are a lot of countries in the world where one person makes the decision. They’re called dictators,” said Representative Steny Hoyer, the second highest-ranking Democrat in the House.

“Our Founding Fathers did not want dictators running America,” he said.

The resolution, if it becomes law, would not stop Trump or future US presidents from taking military action if they determine there is an imminent threat from Iran.

The Soleimani strike angered Iraqi leaders, who called for the ouster of US forces. Some questioned whether Shiite militias carried out the attack in a country that still is trying to eliminate Islamic State fighters.