The House voted Friday to extend funding for an insurance program that covers 9 million children, as Republicans nudged aside Democrats who said lawmakers shouldn’t have tapped Obamacare to pay for the bill.

Approved 242-174, the bill reauthorizes the Children’s Health Insurance Program for five years. The program insures children whose parents earn too much money for Medicaid coverage but still struggle to afford insurance.

Congress allowed federal funding for the program to lapse Oct. 1, meaning some states could run out of money by December.

Nearly every Republican and just 15 Democrats voted for the House bill, after bipartisan talks descended into a food fight over how to fund it. It is unclear if this version can pass muster in the Senate, where at least eight Democrats would have to sign onto the plan to overcome a filibuster.

Reauthorization might have to be rolled into a year-end spending deal, though Republicans said U.S. families are counting on Congress to act now.

“The idea of waiting around another two months before acting on CHIP is simply unacceptable,” Rep. Earl L. “Buddy” Carter, Georgia Republican, said.

Bipartisan House negotiations broke down over series of controversial offsets, such as cutting more than $6 billion from Obamacare’s prevention and public health fund, which pays for things like access to vaccines, opioids prevention and efforts to fight disease.

Republicans also want to shorten the grace period for Obamacare customers who fail to pay their premiums from 90 days to 30. Cutting off their coverage sooner would save money, Republicans say, because taxpayers wouldn’t have to keep paying exchange subsidies and cost-sharing payments for the delinquent customers.

Democrats contend the change would result in roughly 700,000 losing coverage.

“I have tried for months to negotiate with Republicans to develop a bipartisan compromise. But House Republicans chose to spend the first nine months of this year trying to repeal the Affordable Care Act,” Rep. Frank Pallone, New Jersey Democrat, said.

Another provision would force wealthy Medicare recipients to pay more, saving $5.8 billion but drawing a rebuke from AARP, which lobbies for older Americans.

Energy and Commerce Committee Chairman Greg Walden said Democrats have supported the measure before, so this time shouldn’t be different.

Yet Mr. Pallone said there was plenty to complain about in the bill, including a $1 billion boost in Medicaid funding for Puerto Rico that Democrats slammed as “woefully inadequate.”

“It will go to the Senate, and it will sit there,” he said.

Yet more than a dozen Democrats were willing to back the bill, saying low-income constituents are counting on Congress to get moving on a solution.

“I will continue to work with members on both sides of the aisle to ensure Arizona families have the affordable health care coverage they need,” said Rep. Kyrsten Sinema, Arizona Democrat who recently launched a 2018 Senate bid.