Trump signs bill to reopen government for 3 weeks Trump says he feels a deal can ultimately be struck that works for all.

Late Friday night, President Donald Trump signed a bill passed by Congress that officially reopens the federal government for three weeks while lawmakers negotiate border security funding with the president -- ending the longest government shutdown in U.S. history.

"I am very proud to announce today that we have reached a deal to end the shutdown and reopen the federal government," Trump said earlier on Friday, in a surprise development that thrilled hundreds of thousands of federal workers that have been toiling without pay for more than a month.

The bill passed by Congress, sources told ABC News, includes no funding for the president’s long-sought border wall.

The president said earlier on Friday that while has decided not to declare a national emergency at this time, he has the ability to do so if members of Congress do not work on a deal for border security.

"If we don't get a fair deal from Congress, the government either shut down on February 15th again or I will use the powers afforded to me under the laws and the constitution of the United States to address this emergency," Trump said.

Later on Friday, White House press secretary Sarah Sanders tweeted that the administration would move forward in three weeks with building a wall.

While the president has been slim on the details of the agreement, he did reference a conference committee of House and Senate leaders will act in “good faith” to reach an agreement on border security.

“Over the next 21 days, I expect both Democrats and Republicans will operate in good faith. This is an opportunity for all parties to work together for the benefit of our whole, beautiful and wonderful nation,” Trump said.

The president and members of his administration have been criticized for their responses to the financial hardships faced by many federal workers missing pay. But on Friday the president specifically thanked federal workers who have endured the shutdown and said he will see to it that they receive back-pay "very quickly or as soon as possible."

"I want to thank all of the incredible federal workers and their amazing families who have shown such extraordinary devotion in the face of this recent hardship," Trump said.

It's unclear exactly when federal workers could begin to see their back pay, but the White House said workers should expected to be paid in the "coming days." Over 800,000 federal workers were furloughed or worked without pay during the shutdown, forcing some to turn to food banks, charities and even put on fundraisers to make ends meet.

"Recognizing the urgency of getting Federal employees paid quickly, the administration is taking steps to ensure that they receive pay as soon as possible. Since specific payroll issues vary by agency, employees can find more information about paycheck details by reaching out to their agency," a senior administration official told ABC News. The president of the National Treasury Employees Union Tony Reardon said checks should go out as soon as possible. “Get the checks out now. Federal employees haven’t been paid in more than a month and mortgage and rent are due next week. They shouldn’t have to wait a minute longer,” he said.

Congress has been trying to come to a deal to reopen the government, ending the longest shutdown in U.S. history.

After Democrats rejected a proposal to temporarily reopen government with a pro-rated amount of border wall funding Thursday evening, Sen. Lindsey Graham told reporters Friday morning that Republican senators were looking to the White House to decide the next move.

Bipartisan talks about a possible short-term compromise – a three-week stopgap funding bill to reopen the government – began late Thursday between Senate Majority Leader Mitch McConnell and Minority Leader Chuck Schumer.

A Senate Republican leadership aide says the GOP is "very wary" of President Trump, pointing out McConnell has been stung by Trump before. The aide is adamant that the president won't announce a “McConnell deal” – this is a “President-Democrats deal.”

In a press conference on Capitol Hill, Schumer and Speaker of the House Nancy Pelosi thanked federal workers for enduring the 35 day shutdown that appeared to have no end in sight.

"We cannot ever hold American workers hostage again," Schumer said.

"The American people do not like it when you throw a wrench into the lives of government workers over an unrelated political dispute," Schumer said. "Working people throughout America empathized with the federal workers and were aghast at what the president was doing to them. Hopefully, now the president is learned his lesson."

Pelosi, who was able to make the president capitulate on postponing his State of the Union address, said she is "optimistic" that the government will not shut down again after February 15.

"I can't assure the public on anything that the president will do, but I do have to say I'm optimistic. I see every challenge or every crisis as an opportunity, an opportunity to do the right thing for the American people and at the same time make people aware of what the decisions are that we have here and hopefully that will make everybody come together in a way that is unifying for our country," Pelosi said.

After weeks of political tit-for-tat and a stare off between the president and Pelosi, Schumer said that the president's decision today shows that "no one should ever underestimate the speaker, as Donald Trump has learned."

Two sources close to Pelosi say she has not spoken to Trump since he walked out of a meeting in the Situation Room with congressional leaders on January 10.

Still, the president expressed optimism that a deal on border security could be reached with Democrats.

“I think we have a chance, yeah. I think we have a good chance. We’ll work with the Democrats and negotiate and if we can’t do that, then we’ll do a – obviously, we’ll do the emergency because that’s what it is. It’s a national emergency,” Trump said.

After the measure passed both chambers of Congress, House Whip Steny Hoyer stood on the floor and summed up the protracted saga.

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