WASHINGTON (AP) — The House on Thursday passed a stopgap spending bill to prevent a government shutdown this weekend and buy time for challenging talks on a wide range of unfinished business on Capitol Hill.

The measure passed mostly along party lines, 235-193, and would keep the government running through Dec. 22. The Senate was expected to swiftly approve the measure as early as Thursday night and send it to President Donald Trump.

The vote came as Trump and top congressional leaders in both parties huddled to discuss a range of unfinished bipartisan business on Capitol Hill, including the budget, a key children's health program and aid to hurricane-slammed Puerto Rico, Texas and Florida — and, for Democrats and many Republicans, protections for immigrants brought to the country illegally as children.

"We are here to make progress. We have some important issues that we share with you," House Democratic Leader Nancy Pelosi told Trump at the White House, ticking off issues including the opioid crisis, funding for veterans and an expired children's health insurance program. "All things that have bipartisan support in the Congress."

Trump relied, "That's very true."

Those negotiations are sure to be tricky. Pelosi staked out a hard line on Thursday and insisted that any year-end deal would include help for "Dreamer" immigrants, many of whom have only known America as their home. The immigrants are viewed sympathetically by the public and most lawmakers but face deportation in a few months because Trump reversed administrative protections provided to them by former President Barack Obama.

Pelosi told reporters before the meeting that "We will not leave here" without helping the immigrants. Her stance was noteworthy because GOP leaders are likely to require Democratic votes for the pre-Christmas spending bill.

Pelosi returned from the White House to oppose Thursday's stopgap bill. Fourteen Democrats supported the measure, however, while 18 Republicans were opposed.

Among Republicans, the conservative House Freedom Caucus had resisted the pending stopgap measure earlier in the week, fearing it would lead to a bad deal for conservatives down the road. But on Thursday, the group's chairman, Rep. Mark Meadows, R-N.C., said the group will likely give leaders whatever support they need to pass the legislation.

Meadows said they'll help it pass to avoid distractions from the GOP drive to push their treasured $1.5 trillion tax bill through Congress this month. That measure, which mostly benefits businesses and upper-income people, is Trump's and the GOP's top remaining priority and would be their first major legislative triumph of the year.

But hours before Trump was to bargain with congressional leaders at the White House over longer-term spending decisions, Meadows said the conservatives would oppose any agreement they feel allows excessive federal spending.

"I want to avoid a headline that says President Trump's administration just passes the highest spending levels in U.S. history," Meadows told two reporters. "There will be zero support on numbers that are too high, regardless of anybody's position on that."

He also said Ryan promised he'd fight in coming weeks to pass a full-year budget for the military and leave fights with Democrats over domestic spending for later. It is unclear how that strategy would work, since Republicans control the Senate 52-48 and will need at least eight Democratic votes to pass any spending legislation.

The prospects for successful White House talks were buffeted Wednesday when the impulsive Trump blurted to reporters that a shutdown "could happen." He blamed Democrats, saying they want "illegal immigrants pouring into our country, bringing with them crime, tremendous amounts of crime."

Last week, an unexpected attack by Trump on Senate Minority Leader Chuck Schumer, D-N.Y., and Pelosi prompted the two to skip a bargaining session that was planned then.

This time, the White House smoothed the waters by following up with a more peaceable, written statement. It praised Pelosi and Schumer for choosing to "put their responsibility to the American people above partisanship" and said Trump was anticipating productive talks between "leaders who put their differences aside."

The two-week spending bill also makes money available to several states that are running out of funds for the Children's Health Insurance Program. That widely popular program provides medical care to more than 8 million children.

While many Democrats seemed likely to oppose the short-term bill, enough were expected to support it in the Senate to allow its passage there. They know they'd still have leverage on subsequent bills needed to keep the government running.

Democrats promise to us their leverage to insist on spending boosts for health care, infrastructure and other domestic programs that would match increases Republicans want for defense.