Donald Trump has signed a bill to end the three-day government shutdown after Democrats reluctantly voted to temporarily pay for resumed operations.
In return, Republican leadership gave assurances the Senate will find a fix for the plight of young immigrant "dreamers" in the coming weeks.
Trump signed the measure behind closed doors at the White House after the House approved the measure.
The president issued a statement saying he was pleased congressional Democrats had "come to their senses," saying his administration would make a long-term immigration deal "if and only if it's good for the country."
"Once the government is funded, my administration will work toward solving the problem of very unfair illegal immigration," the statement read.
In ending the impasse, Democrats prompted a backlash from immigration activists and liberal base supporters who wanted them to fight longer and harder for legislation to protect from deportation of some 700,000 immigrants who were brought to the country as children.
Despite Republican assurances, deep divides have opened in the Democratic caucus over the strategy, as red-state lawmakers fighting for their survival broke with progressives looking to satisfy liberals' and immigrants' demands.
Under the agreement, Democrats provided enough votes to pass the stopgap spending measure keeping the government open until February 8.
In return, Majority Leader McConnell agreed to resume negotiations over the future of the dreamers, border security, military spending and other budget debates.
If those talks do not yield a deal in the next three weeks, the Republican promised to allow the Senate to debate an immigration proposal - even if it is one crafted by a bipartisan group and does not have the backing of the leadership and the White House, lawmakers said.
McConnell had previously said he would bring a deal to a vote only if President Donald Trump supported it.
Sixty votes were needed to end the Democrats' filibuster, and the party's senators provided 33 of the 81 the measure got.
Eighteen senators, including members of both parties, were opposed. Hours later the Senate passed the final bill by the same 81-18 vote, sending it to the House, which quickly voted its approval and sent the measure on to Trump.
White House press secretary Sarah Sanders predicted that operations would return to normal by Tuesday morning.