When is the United States on the sidelines, and when is it at war?

That question is at the heart of the debate over an unprecedented congressional challenge to the Trump administration’s support of Persian Gulf nations mired in Yemen’s civil war.

Voting 247 to 175, largely along party lines, House lawmakers on Thursday passed a measure that for the first time uses the ­Vietnam-era War Powers Resolution to force an end to U.S. participation in an overseas conflict.

President Trump is expected to veto the legislation, which culminates several years of congressional opposition to the U.S. involvement in the war. The war has pitted Saudi Arabia and other gulf nations against the Houthi rebel group in what has become a proxy conflict between U.S. allies and Iran.

The resolution — approved in the Senate last month — says the U.S. military has “been introduced into hostilities” in Yemen, “including providing to the ­Saudi-led coalition aerial targeting assistance, intelligence sharing, and midflight aerial refueling.”

The Trump administration has argued that because the military is not dropping bombs or sending ground troops into combat, it plays a supporting role that cannot be constrained by the resolution.

In a 2018 letter to the Senate leadership, the Pentagon’s general counsel said “limited” U.S. support did not meet the legal threshold for hostilities because U.S. forces have not — with the exception of one self-defense incident in 2016 — exchanged fire with the Houthi forces.

After Thursday’s vote, Cmdr. Rebecca Rebarich, a Pentagon spokeswoman, said in a statement that the Defense Department had been “transparent in dialogue with Congress that DoD support to the Saudi-led Coalition does not constitute involvement in hostilities.”

When the Yemen conflict erupted in 2015, the Obama administration agreed to refuel coalition jets and provide other forms of military support from afar.

The administration later cut back on some assistance, including an advisory mission at the Saudi air headquarters, and suspended sales of certain weapons to Saudi Arabia. The kingdom is a massive purchaser of U.S. weaponry.

The Trump administration, energized by its quest to curb Iranian influence, has been more supportive of Saudi Arabia, though its push for closer ties has been tempered by concerns about Yemen’s massive humanitarian crisis and public criticism of repeated deaths in Saudi airstrikes.

The congressional opposition to involvement in Yemen’s civil war gained steam as anger mounted after the grisly slaying of Washington Post contributing columnist Jamal Khashoggi, which many lawmakers blame on leaders in Riyadh. The Saudi government says the kingdom’s most senior figures had no prior knowledge of it.

Rep. Ro Khanna (D-Calif.), a leading House critic of the war, rejected the administration’s reading of the War Powers Resolution. “It does not require us to have ground troops,” he said. “It just requires us to be involved.”

The measure notes the War Powers Resolution’s reference to U.S. forces who are assigned to “command, coordinate, participate in the movement of, or accompany” foreign forces.

But in a sign of lawmakers’ attempt to build a broad coalition of support, the central section of the new legislation specifies that hostilities include refueling, which has already been halted. It would continue to allow intelligence-sharing, one of the other remaining elements of military support, and does not address massive arms sales.

Legal experts said the Trump administration’s argument was consistent with how other administrations have defined hostilities.

In 2011, the Obama administration said its role in the international air operation against Libya leader Moammar Gaddafi, which went beyond the assistance being provided in Yemen, should not be considered hostilities under the War Powers Resolution.

“The problem is that the average person on the street would look at what we’re doing in Yemen, if they knew what we’re doing, and have a hard time concluding that’s not hostilities,” said Stephen ­Vladeck, a professor at the University of Texas School of Law.

A senior Saudi official, speaking on the condition of anonymity to discuss a vote by U.S. lawmakers, said the measure would “not end the conflict in Yemen, nor will it alleviate the challenging humanitarian situation.”

“Regardless of whether the resolution becomes U.S. law or not, Saudi Arabia will continue to lead the effort to restore the legitimate government of Yemen and to counter the expansionist designs of Iran,” the official said. “We have resolved to defend our nation and the region, even if we have to do so with our bare hands.”

The administration has also argued that its military support has made for a more effective air operation and said, without providing details, that civilian casualties have decreased.

The Pentagon is conducting a parallel military operation in Yemen against al-Qaeda in the Arabian Peninsula that is not challenged by the new legislation.

Khanna and a small bipartisan group of lawmakers have requested a meeting with Trump to make their case for why the president, as someone who has advocated pulling out of foreign wars, should end his support for U.S. aid to the coalition in Yemen.

Thursday’s vote marked a rare moment of congressional action to constrain the executive’s warmaking abilities. For years, lawmakers have failed to update the authorization that has been used since 9/11 for a host of conflicts in a host of countries.

Even if it were enacted, the legislation’s effect would be mostly symbolic, since the refueling was halted late last year.

Scott Anderson, a former State Department lawyer who is a fellow at the Brookings Institution, said that no matter its outcome, the discussion surrounding the legislation had raised the profile of the plight of Yemeni civilians and won over a cadre of Republicans.

“After this bill, [supporters] can say a bipartisan majority of Congress wants this to end and the president is going ahead,” he said. “That’s really the hook — to put it on the president’s lap and make him bear the consequences that flow from that.”

Correction: Because of an editing error, an earlier version of this story misstated the Pentagon general counsel’s views. In a letter to the Senate leadership, the general counsel said “limited” U.S. support in Yemen’s conflict did not meet the legal threshold for hostilities, not that it met the threshold.

Karen DeYoung contributed to this report.