The legislation, which would keep the Homeland Security Department and several other government agencies open through Dec. 21, came as the funding for those agencies is set to expire Friday midnight.
The prospect of a partial government shutdown was raised by disagreements among lawmakers over Trump's proposed U.S.-Mexico border wall, for which he has demanded 5 billion U.S. dollars.
Senate Democratic Leader Chuck Schumer has said that Democrats are only willing to agree to a 1.6-billion-dollar budget to bolster border security instead of building a physical wall.
Republicans currently hold 51 seats in the Senate and need nine Democratic votes to pass a spending bill.
Trump had threatened to force a partial government shutdown if the Congress did not give him enough funding for the wall.
The White House and congressional leaders agreed to the two-week funding extension in light of the death of former President George H.W. Bush last week.
On Thursday, both the House of Representatives and the Senate passed the continuing resolution to extend the federal government funding.
The U.S. Congress had already passed spending bills for five government agencies for the fiscal year 2019, which began on Oct. 1, and it still needs to decide on the funding for seven more agencies, including the Homeland Security Department, the Justice Department, and the Agriculture Department.
The federal government was briefly shut down twice this year due to lawmakers' discrepancy on immigration issues.