WASHINGTON — The House on Thursday gave final passage to a bipartisan resolution forcing an end to United States military involvement in Saudi Arabia’s war in Yemen, sending President Trump a pointed rebuke over his continued defense of the kingdom after the killing of a dissident journalist, Jamal Khashoggi.

The 247-to-176 vote, with 16 Republicans joining all House Democrats, invoked the rarely used War Powers Act to curb the president’s executive power to wage war without congressional approval. It most likely sets up the second veto of Mr. Trump’s presidency, this time to publicly defend a four-year conflict that the United Nations has deemed the world’s worst humanitarian crisis, with thousands of civilians killed and millions suffering from famine.

The Senate passed the resolution in March, 54 to 46.

“The vote in the Senate and in the House makes it clear that the United States will not continue to follow the despotic, anti-democratic leadership coming out of Saudi Arabia,” said Senator Bernie Sanders, independent of Vermont and one of the lead sponsors of the resolution. “The United States should not be led into a war by a despotic, undemocratic, murderous regime.”

Supporters of the Yemen resolution have faced a grueling road in recent months to get the legislation onto the president’s desk. The Senate — led by the resolution’s authors, Senators Mike Lee, Republican of Utah; Christopher S. Murphy, Democrat of Connecticut; and Mr. Sanders — first passed the measure 56 to 41 in December, but Paul D. Ryan, the House speaker at the time, refused to take it up.