President Donald Trump signed legislation Friday to temporarily end the record long government shutdown, resolving the grueling 35-day closure but not the fight over his proposed border wall.

The measure funds the government for three weeks, until Feb. 15, while lawmakers try to reach a wider deal on immigration. Both the House and Senate passed the plan by voice vote on Friday.

Trump had demanded $5.7 billion to build his border wall before he agreed to end the partial closure — but relented on Friday. Congress will set up a bipartisan, bicameral conference committee to try to strike a deal on border security.

Trump again argued for a border wall Friday — and threatened to let funding lapse or even declare a national emergency if Congress does not craft an immigration deal he likes. The president agreed to end the shutdown as the pain from the wall impasse sharpened.

Trump left the political fight battered, faced with flagging approval ratings, an unfulfilled campaign promise and most of the blame for an episode that disrupted millions of American lives. As some conservatives criticized him for supporting a plan he originally planned to veto, Trump defended his decision to reopen the government on Friday.

"This was in no way a concession," the president wrote in a tweet. "It was taking care of millions of people who were getting badly hurt by the Shutdown with the understanding that in 21 days, if no deal is done, it's off to the races!"

Trump tweet

About 800,000 federal workers started to miss their second paychecks Friday since funding lapsed last month. Many had to scramble to cover meals and bills during the closure. If the plan becomes law, they are expected to get back pay in four to five days, an administration official told CNBC on Friday.

The Trump administration had faced backlash for a perceived lack of empathy toward the government workers. The president repeatedly claimed many federal employees agreed with his tactics — though union officials and the vast majority of government workers denied that. His wealthy Commerce Secretary Wilbur Ross also sparked criticism when he said he did not "understand why" workers went to food banks instead of taking out loans.

Democrats pounced on every perceived misstep. They had repeatedly urged Trump to reopen the government before lawmakers had a border security debate. Speaking after the president announced a deal to fund the government on Friday, Senate Minority Leader Chuck Schumer said that "we can never hold American workers hostage again."

House Majority Leader Steny Hoyer, D-Md., echoed Schumer after the House approved the funding measure Friday.

"I hope the experience of the last 35 days has taught us that we should never repeat this exercise of shutting down government again," he said.

The deal only temporarily delays another shutdown — or a potential constitutional fight over the president's power to declare a national emergency. Lawmakers may still fail to reach an immigration deal that satisfies Trump.

Meanwhile, Republicans hinted at more conflict to come. In a tweet, White House press secretary Sarah Huckabee Sanders said Trump "is moving forward building the wall with or without the Democrats."

Rep. Mark Meadows, a North Carolina Republican and Trump ally, also tweeted that "compromise is important, but not required, to secure our border and protect American families."

The Senate chose seven members, all on the Appropriations Committee, to send to the conference committee on Homeland Security spending:

Sen. Richard Shelby, R-Ala. (Appropriations Committee chairman)

Sen. Roy Blunt, R-Mo.

Sen. Shelley Moore Capito, R-W.V.

Sen. John Hoeven, R-N.D.

Sen. Patrick Leahy, D-Vt. (Appropriations Committee vice chairman)

Sen. Dick Durbin, D-Ill. (Senate Minority Whip)

Sen. Jon Tester, D-Mont.

House Democrats chose six members from the House Appropriations Committee for the conference. It was not immediately clear who would represent the Republican side.

Rep. Nita Lowey, D-N.Y. (Appropriations Committee chairwoman)

Rep. Lucille Roybal-Allard, D-Ca.

Rep. David Price, D-N.C.

Rep. Barbara Lee, D-Ca.

Rep. Henry Cuellar, D-Texas

Rep. Pete Aguilar, D-Ca.

— CNBC's Eamon Javers contributed to this report.

Subscribe to CNBC on YouTube.