WASHINGTON—House Republicans’ slimmed-down plan to try to avert a government shutdown was defeated in a hastily called vote Thursday, as several dozen GOP lawmakers joined with Democrats in rejecting the proposal endorsed by President-elect Donald Trump .

The revised legislation proposed extending government funding for three months and providing more than $100 billion in disaster relief and aid for farmers, while stripping out a series of other provisions, such as restrictions on investments in China, 9/11 healthcare funds and new rules on pharmacy-benefit managers. It also proposed suspending the nation’s borrowing limit for two years.

It had 174 votes in favor and 235 against, with one member voting present, well short of the two-thirds supermajority required under special fast-track procedures. Crucially, it also was shy of a simple majority of the GOP-controlled chamber, dimming its chances of being brought to the floor again and marking an embarrassing setback for both Trump and embattled House Speaker Mike Johnson (R., La.).

In all, 38 Republicans, mostly fiscal hardliners, voted against the bill, along with almost all Democrats. Two Democrats—Reps. Kathy Castor of Florida and Marie Gluesenkamp Perez of Washington—voted in favor of the measure. Rep. Marcy Kaptur (D., Ohio) voted present.

If no bill is passed and signed into law by President Biden by 12:01 a.m. Saturday, the federal government would partially shut down , furloughing hundreds of thousands of federal workers, though critical services would continue to function.

The vote came a day after Trump killed a bipartisan deal backed by Johnson and other congressional leaders that had drawn widespread criticism from rank-and-file GOP lawmakers. The new legislation came in at 116 pages, down from the 1,547 pages in the original bill. As with the initial proposal, the bill would extend government funding until March 14.

“This is Washington. This is how lawmaking is done. It’s a long process. Sometimes it takes a while for getting consensus,” said Johnson as the voting got under way. After the bill failed, he said Republicans “will regroup and we will come up with another solution.” He didn’t respond when asked if the debt-ceiling provision would have to come out of the bill.

Told you so, said Democrats after the vote. “It’s a good thing the bill failed in the House. And now it’s time to go back to the bipartisan agreement,” said Senate Majority Leader Chuck Schumer (D., N.Y.)

Trump had hailed the new plan unveiled Thursday afternoon as a “very good deal” for the American people, and praised its provision suspending the nation’s borrowing limit until January 2027. But the approach was immediately rejected by Democrats, and the floor debate ahead of the vote grew raucous, with Republicans who said that Democrats would be blamed for a shutdown being drowned out by boos.

The presiding lawmaker, Rep. Marc Molinaro (R., N.Y.), broke his gavel trying to bring the floor to order. Senators wandered into the chamber to watch the drama.

The defeat of the bill put the path forward back in limbo. All day, the leaders of different Republican factions filed into Johnson’s office, only to emerge hours later unable or unwilling to answer questions about what’s next.

Even if a measure passes the House, it would need to be approved by the Democratic-controlled Senate. Angry Democrats signaled Thursday they are in no mood to play ball after Trump and his billionaire ally Elon Musk on Wednesday torpedoed the deal Johnson and other congressional leaders struck earlier this week.

Talk circulated among lawmakers about a possible weeklong funding extension, which would push the shutdown deadline past Christmas. But that too would need bipartisan support to get through the Senate.

Trump had told Republicans that he wanted a stopgap bill that included disaster relief and aid for farmers. He also wanted the bill to raise or eliminate the nation’s debt ceiling, which must be adjusted regularly to allow the U.S. to continue paying its creditors and avoid default.

He demanded Republicans drop what he called “bells and whistles,” a reference to a slew of unrelated provisions in the original bill. He also threatened that any Republican who opposed a debt-ceiling adjustment would face a primary challenge in the next election.

The debt ceiling, which hadn’t figured in the weeks of talks crafting the now-dead deal, was a major sticking point, as many Republican spending hawks oppose raising the debt ceiling on principle. Seventy-one House Republicans voted against the last debt-ceiling increase in May 2023.

Rep. Chip Roy (R., Texas), a prominent opponent of the revised bill, blasted his colleagues in a speech on the House floor. “I’m absolutely sickened by a party that campaigns on fiscal responsibility and has the temerity to go forward to the American people and say you think this is fiscally responsible,” he said.

After the vote, Roy said he was happy to talk to Trump and Johnson, but he wouldn’t vote for a debt ceiling increase without specific spending cuts.

Earlier Trump had targeted Roy on Truth Social, calling for primary challengers against him in 2026. “Chip Roy is just another ambitious guy, with no talent,” Trump said.

House Democrats were furious that Republicans had pulled out of the original deal, and House Minority Leader Hakeem Jeffries (D., N.Y.) told his conference to reject the revised plan.

“The Musk-Johnson proposal is not serious. It’s laughable. Extreme MAGA Republicans are driving us to a government shutdown,” Jeffries said.

The White House has been in close touch with Democratic leaders, and they are coordinating on strategy, said a person familiar with administration thinking.

Sen. Lindsey Graham (R., S.C.) said the reality is that Republicans will need Democratic votes, both in the Senate, which has a 60-vote threshold to advance most legislation, and in the House where Republicans hold a very narrow majority.

GOP detractors complained that Johnson conceded too much in talks with Democrats and allowed a bill intended as a simple stopgap measure to be crammed with unrelated provisions. Critics also said that there isn’t enough time for lawmakers to review such a massive bill.

The GOP setbacks raised doubts about the future for Johnson, who until this week had been seen as a shoo-in to be elected speaker when the new House votes on Jan. 3. Now, several GOP lawmakers are indicating they would oppose him, given his handling of the stopgap bill.

Trump said he continued to back Johnson in the role. In an interview with Fox News Digital, he said that Johnson would “easily remain speaker” if he “acts decisively and tough” to eliminate “all of the traps being set by Democrats.”

Republicans have struggled for the past two years to pass major funding bills, with party leaders heavily dependent on Democratic votes. The GOP majority in the House currently stands at 219 to 211. In the wake of the November election, the Republicans will likely have a 219-215 margin on the first day of the new Congress.

Write to Katy Stech Ferek at katy.stech@wsj.com , Lindsay Wise at lindsay.wise@wsj.com and Siobhan Hughes at Siobhan.hughes@wsj.com