WASHINGTON — Congress on Thursday gave final approval to a short-term spending bill that would punt the threat of a government shutdown to just before Thanksgiving, giving lawmakers an additional two months to resolve their differences over paying for President Trump’s policies.

The measure ensures that all federal agencies and departments, as well as a number of health care and community programs, will maintain their funding through Nov. 21, just before Congress is scheduled to depart Washington for its Thanksgiving break. The Senate voted 82 to 15 to pass the bill, clearing it for the White House just days before funding was set to expire on Oct. 1. Mr. Trump is expected to sign it.

“That’s the easy part,” Senator Chuck Schumer, Democrat of New York and the minority leader, said Thursday in a floor speech. “The hard part is getting a bipartisan appropriations process back on track.”

That task promises to be a difficult one, given bitter differences between Democrats and Republicans over several elements of Mr. Trump’s agenda, none more acute than the disputes over financing construction of a wall on the southwestern border, and his immigration policies.