Republican leaders rushed the bill to the floor using a procedure normally reserved for uncontroversial legislation. But the bill ignited passions among supporters and critics.

The Senate passed a similar bill last year, and Mr. Trump supported the legislation.

The House Republican leader, Kevin McCarthy of California, said the bill was not dead. “We will try again, pass legislation and bring hope to those whose only desire is the right to try to live,” he said.

The bill could be brought up again under rules that allow passage with a simple majority.

Going into the debate on Tuesday, supporters of the bill expressed confidence that it would win approval.

“Our bill will give some relief to terminally ill patients who have no further options left to extend their lives,” said Representative Andy Biggs, a freshman Republican from Arizona, where a state right-to-try measure won 78 percent of the vote in a 2014 referendum. “All Americans have the right and freedom to try to save their lives.”

But many doctors and advocates for patients oppose the legislation.

“Supporters of this legislation talk as if effective treatments are being withheld from patients,” said Dr. Robert M. Califf, who was the commissioner of the Food and Drug Administration under President Barack Obama. “The vast majority of experimental therapies are toxic or ineffective. The only way we find out is through controlled studies where we measure the effects.”