From left: President Donald Trump, Senate Majority Leader Mitch McConnell, and Senate Minority Leader Chuck Schumer. Kevin Lamarque/Reuters President Donald Trump bucked his own party's leaders and sided with Democrats on a deal to bundle Hurricane Harvey relief funds, a three-month debt-limit increase, and a three-month continuing resolution to keep the government funded.

Trump agreed to the deal, which Senate Minority Leader Chuck Schumer and House Minority Leader Nancy Pelosi supported. Senate Majority Leader Mitch McConnell and House Speaker Paul Ryan were opposed.

"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," Schumer and Pelosi said in a statement. "Both sides have every intention of avoiding default in December and look forward to working together on the many issues before us."

According to a source briefed on the meeting, the leaders were deadlocked over how long to raise the debt ceiling. Schumer and Pelosi wanted the shorter three-month extension, while McConnell, Ryan, House Majority Leader Kevin McCarthy, and Treasury Secretary Steven Mnuchin wanted a longer one.

As the leaders appeared ready to agree to disagree, the source said, Trump interjected and said the group should go with a three-month debt-limit extension and a three-month continuing resolution.

Republicans would have preferred a longer extension to avoid another fight in December. Democrats could use the opportunity as leverage to attach a provision aimed at codifying into law the Deferred Action for Childhood Arrivals program, which the Trump administration said Tuesday would be phased out over the next six months.

Ryan had hours earlier called a three-month debt-limit increase "ridiculous" and said Democrats were trying to "play politics" by suggesting tying in aid for Harvey relief.

Trump confirmed the deal while speaking to reporters on Air Force One.

"We had a very good meeting with Nancy Pelosi and Chuck Schumer," Trump said. "We agreed to a three-month extension on debt ceiling, which they consider to be sacred — very important — always we'll agree on debt ceiling automatically because of the importance of it."

Trump said the extensions for the debt limit and government funding would run through December 15.

"We essentially came to a deal, and I think the deal will be very good," Trump added. "We had a very, very cordial and professional meeting."

A Republican close to leadership told Jonathan Swan of the news website Axios that the concession to a short-term debt-limit increase was a big win for Democrats.

"Dems bluffed their way into total victory," the Republican said. "They win the politics of DACA and leverage on debt in the winter. The fate is sealed — DACA will be reauthorized without strings, Schumer has inserted himself into all negotiations in the winter, including tax, spending, and immigration."

According to reports, Republicans in the meeting originally suggested raising the debt ceiling for 18 months, then offered to compromise at six months. Democrats turned down the idea and pitched the three-month debt-limit increase.

Conservative Republicans, including the House Freedom Caucus and Sen. Rand Paul, oppose combining Harvey relief with any other measure, so the legislation would most likely take many Democrats to pass.