The legislation holds government funding at current levels through Dec. 20, setting up yet another appropriations showdown. Funding will lapse Friday if the president does not approve the spending bill.

The Democratic-held House passed it on Tuesday by a 231-192 margin, seeing considerably more Republican opposition than the GOP-controlled Senate did.

The measure now heads to President Donald Trump, who barring a change of heart, is set to sign it into law. The Senate approved it in a 74-20 vote.

The measure gives the House and Senate a few extra weeks to hash out a long-term spending deal. Lawmakers failed to strike an agreement before funding ran out this week amid another dispute over border security funding.

Earlier this year, Congress passed a two-year deal to set budget levels and suspend the U.S. debt ceiling. The House and Senate have struggled to decide how specifically to allocate the money to federal departments.

Trump has pushed for billions of dollars more to build a proposed wall on the U.S.-Mexico border. Speaking earlier Thursday, Senate Minority Leader Chuck Schumer, D-N.Y., urged the president to stay out of the appropriations process.

"With another month's time at our disposal, the appropriations process can now go down one of two paths," he said. "On the first path, President Trump stays out of our way and gives Congress the space to work together and find an agreement. On the second path, President Trump stomps his feet, makes impossible demands and prevents his party, the Republicans, from coming to a fair arrangement."

Subscribe to CNBC on YouTube.