With fewer than three hours left until a midnight deadline set by the U.S. Treasury Department, lawmakers in both chambers managed to pass a bill to reopen the government and avoid default on America’s debt.

The Senate passed the measure first Wednesday evening, by a vote of 81-18. House lawmakers followed suit a few hours later with a vote of 285-144.

The legislation ends a 16-day government shutdown prompted by Republican-led efforts to defund the Affordable Care Act. Once signed into law, it will keep the government open until Jan. 15 and postpone the next debt ceiling debate until Feb. 7. In one concession to Republican demands, the bill requires income verification for those who receive subsidies under the Affordable Care Act.

The president has said he would sign the bill into law as soon as it comes to his desk.