(Recasts with comments by Schumer, McConnell, details on meeting)
WASHINGTON, Sept 6 (Reuters) - President Donald Trump, siding with Democrats over fellow Republicans, reached a deal with congressional leaders of both parties to extend the U.S. debt limit until Dec. 15 as well as avoid a government shutdown and provide disaster relief.
The agreement marked a rare instance of bipartisan compromise since Trump took office in January. If passed by the Republican-led Congress, it would avert an unprecedented default on U.S. government debt, keep the government funded for the first three months of the fiscal year beginning Oct. 1 and provide aid to victims of Hurricane Harvey.
Trump has tangled repeatedly as president with top House of Representatives Democrat Nancy Pelosi and top Senate Democrat Chuck Schumer but embraced their proposal - ridiculed by Republican leaders - for a three-month debt limit extension.
"This is a really positive step forward," Schumer later told reporters. "It was a really good moment of some bipartisanship."
"The nation can breathe a sigh of relief. We've avoided default. We've avoided government shutdown," Schumer said.
Senate Majority Leader Mitch McConnell, whose views were overruled by Trump, said he would bring the agreement to the Senate floor for a vote.
"His feeling was that we needed to come together, to not create a picture of divisiveness at a time of genuine national crisis," McConnell told reporters, referring to Trump. "And that was the rationale, I'm confident, for his decision to agree to what I'm going to be offering" on the Senate floor."
A Republican congressional aide briefed on the meeting said Republican leaders pushed in the meeting for an 18-month debt limit hike, then floated six months as a possibility. The aide said Pelosi and Schumer dismissed a six-month hike and Trump then agreed to the Democrats' proposal.
Washington has suffered through bitter partisanship that has at times left the U.S. capital dysfunctional under Trump and his Democratic predecessor Barack Obama.
Trump described the talks at the White House as cordial and professional.
"We had a very good meeting with Nancy Pelosi and Chuck Schumer," Trump told reporters aboard Air Force One, without mentioning McConnell or Republican House Speaker Paul Ryan.
"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.
Word of the deal helped push the dollar to the day's highs against the euro and yen, and gave a lift to benchmark U.S. equity indexes. Yields on most Treasury debt securities rose as the reduced risk of a default undercut safe-haven flows that had supported bond prices over the last several days.
A source briefed on the meeting said Treasury Secretary Steve Mnuchin and all Republicans there argued for a debt limit increase for a longer period. But by the end of the meeting, Trump sided with Democrats who wanted a three-month increase.
Earlier in the day, Ryan had called the Democratic proposal for a three-month increase a "ridiculous and disgraceful" idea that would "play politics with the debt ceiling."
Trump has had fraught relations with both McConnell and Ryan.
Earlier in the day, Schumer had called Trump's decision to terminate the Deferred Action for Childhood Arrivals (DACA) program created in 2012 by Democratic former President Barack Obama "heartless and brainless," a day after Pelosi labeled Trump's action a "shameful act of political cowardice."
The Treasury Department has said the ceiling must be raised in the next few weeks. If not, the government would be unable to borrow more money or pay its bills, including its debt payments. That could hurt the United States' credit rating, cause financial turmoil, harm the U.S. economy and possibly trigger a recession.
Trump also expressed optimism toward Congress reaching a deal to decide the fate of 800,000 young adults who were brought into the United States illegally as children - the so-called Dreamers - after he rescinded on Tuesday a five-year-old program that had protected them from deportation, effective in March.
"I'd like to see a permanent deal, and I think it's going to happen. I think we're going to have great support from both sides of Congress," Trump said.
Schumer urged Republicans to put forward legislation protecting the Dreamers without other issues attached. Ryan said any legislation to address the Dreamers would also need to address border security.
The House on Wednesday approved roughly $8 billion in initial emergency aid for relief and rebuilding after Hurricane Harvey, which tore into Texas on Aug. 25. The measure, which provides $7.4 billion for the Federal Emergency Management Agency and $450 million for the Small Business Administration, will now go to the Senate and, barring unexpected setbacks, could be on Trump's desk to sign by the end of the week.
The party in power, in this case Republicans, often argues for as long of a debt limit increase as possible for two reasons. It protects members of Congress from casting multiple votes on the politically unpopular legislation over a short period of time, especially in the run-up to the 2018 congressional elections, and it lends added stability to financial markets. (Additional reporting by Jeff Mason, Roberta Rampton, Amanda Becker, Doina Chiacu, Richard Cowan, James Oliphant and David Morgan; Writing by Will Dunham; Editing by Alistair Bell and Andrew Hay)