President Trump has forged an agreement with Democratic leaders to pass aid for the Hurricane Harvey relief effort, a three-month extension of the debt limit and a short-term government spending bill that both would expire in mid-December.

The move -- a spontaneous deal with House Minority Leader Rep. Nancy Pelosi and Senate Minority Leader Charles Schumer -- dumbfounded GOP leadership and senior White House staff, CBS News' Major Garrett reports, citing several conversations inside and outside the White House.

It was not the plan going into the meeting, and senior aides expected there would be some initial fencing, they'd utter a few pleasantries afterward -- and then continue negotiating.

Get Breaking News Delivered to Your Inbox

Mr. Trump, however, improvised and took the deal for three reasons, Garrett reports.

First, he has lost confidence in House Speaker Paul Ryan and Senate Majority Leader Mitch McConnell to produce the votes of tough issues, and he did not want to be strung along for a lengthy negotiation that could make it look like he couldn't govern.

Second, the president wants to erase the sense of crisis around a potential default or shutdown to give some room for a tax reform conversation.

And third, Democrats have the votes on these issues. Mr. Trump doesn't care that Republicans don't want to vote twice on debt ceiling or the budget. He wants to look like he's managing things, as he has so far with Hurricane Harvey and with preparation for Hurricane Irma. Mr. Trump has seen steadily positive publicity about his management of the weather crisis and wants to maintain and build on it.

Soon after the meeting, Schumer and Pelosi released a statement about the agreement -- which had been made during a meeting with GOP leaders and the president at the White House Wednesday.

"In the meeting, the President and Congressional leadership agreed to pass aid for Harvey, an extension of the debt limit, and a continuing resolution both to December 15, all together. Both sides have every intention of avoiding default in December and look forward to working together on the many issues before us," the two said in the joint statement.

GOP leaders had sought an 18-month hike. This will give Democrats leverage in December.

"Republican leaders pushed for [an] 18-month debt limit hike, then floated 6 months. Pelosi and Schumer dismissed 6-month hike. Trump then agreed to the 3-month hike that Democrats put on the table," said a congressional aide briefed on the meeting. "

Toward the end of the meeting Ivanka Trump entered the Oval Office to "say hello" and the meeting careened off topic. Republican leaders were visibly annoyed by Ivanka's presence."

Earlier in the day, Speaker Paul Ryan scoffed at the idea of a three-month debt limit increase.

"I think that's a ridiculous idea," the Wisconsin Republican said about the idea proposed by Democratic leaders, adding that a short-term debt limit increase would not benefit people in Texas and Louisiana who have to deal with the devastation caused by Hurricane Harvey.

Congress must lift the debt ceiling and pass government funding by the end of September.

"We have many, many things that are on the plate. Hopefully we can solve them in a rational way. And maybe we won't be able to. We'll probably know pretty much at the end of this meeting," Mr. Trump said in a pool spray before the private meeting in the Oval Office kicked off.

The late morning gathering was held with the Big Four: Ryan, Pelosi, Schumer and Senate Majority Leader Mitch McConnell, R-Kentucky.

The meeting came as the House passed the first installment Wednesday of emergency funding for the recovery effort following Hurricane Harvey, which will be immediately sent to the Senate. The upper chamber is expected to attach a "clean" measure to lift the debt ceiling, vote on the package, and send it back to the House for a final vote by the end of the week.

This also comes a day after the Trump administration announced that it was ending the 2012 program created by Obama that has deferred deportations for more than 780,000 people who came to the U.S. illegally as children. Key Republicans including Ryan had called on the president to hold off so that Congress could address the Deferred Action for Childhood Arrivals (DACA) program. The decision gives lawmakers until early March to come up with legislative fix.

Other major items on Congress's plate this fall include tackling health care reform and tax reform.

CBS News' Nancy Cordes contributed to this report.