Image copyright Reuters Image caption Donald and Melania Trump visited Houston to meet volunteers delivering supplies to residents

Donald Trump has agreed to a Democratic plan to lift the debt limit for three months, fund the government and rush aid to Hurricane Harvey victims.

The US president went against Republican leaders who wanted to extend a debt-limit increase for longer, until after the 2018 mid-term elections.

Democrats announced the deal just before the House of Representatives passed $8bn (£6bn) for Harvey victims.

Congress will need to approve the deal before it is finalised.

Mr Trump told reporters aboard Air Force One he had a "very good meeting" with House Minority Leader Nancy Pelosi and Senate Minority Leader Chuck Schumer.

"We essentially came to a deal and I think the deal will be very good," he said while travelling to North Dakota for an event on tax reform on Wednesday.

"We agreed to a three-month extension on debt ceiling, which they consider to be sacred, very important."

The proposal attaches the disaster aid to a government funding bill that would raise the US debt limit and keep the government running through 15 December, setting up a fiscal showdown at the end of the year that Republicans had hoped to avoid.

"Both sides have every intention of avoiding default in December and look forward to working together on the many issues before us," Mrs Pelosi and Mr Schumer said in a joint statement.

Leaders from both parties met Mr Trump at the White House on Wednesday morning.

Following the meeting, Republican House Speaker Paul Ryan called the Democratic proposal "unworkable" and "ridiculous", putting the president at odds with his own party.

'Seething Republicans' - US media reaction

"Meet the swamp: Trump sides with Democrats during leadership confab", comments Breitbart on the front page of its website, adding that by doing so he "jacks up debt, punts the agenda, snubs GOP".

"This isn't Trump caving in to the Democrats. No no no. This is Trump sticking it to the Establishment, you guys. That's all," comments Joe Cunningham of RedState.

"President Trump waged a hostile takeover of the Republican Party's presidential nomination last year. Now he's holding the entire party hostage," says an editorial in The Washington Post.

"The bargain has left several Republican lawmakers seething that Trump, the self-proclaimed deal-maker, had given such leverage to their political rivals," The Los Angeles Times reports. It says that the president has grown increasingly frustrated over dissent in his party which he believes has stifled his agenda.

"[If Mr Trump's] deal did not yet represent the breaking point between the president and his core, hard-right base of support, it certainly put him closer than he has ever been to tipping his fragile political coalition into open revolt," New York Times columnists Jeremy W Peters and Maggie Habierman write.

Treasury Secretary Steve Mnuchin had also reportedly urged Mr Trump to pursue a longer-term debt-limit deal but has insisted that raising the borrowing limit was imperative in order to quickly send aid to Texas.

The deal includes Democratic support in the Senate for the first instalment of disaster relief aid for Hurricane Harvey victims in Houston, where flooding has devastated the Texan city.

Texas Governor Greg Abbott has warned the cost of reconstruction after Hurricane Harvey could be as high as $180bn.

The House overwhelmingly passed a bill to provide $7.9bn for victims of the floods before the Federal Emergency Management Agency (Fema) runs out of funds later this week. The House approved the funding 419 to three, with three Republicans voting "no".

Image copyright AFP/Getty Image caption Thousands have already registered for government assistance in the wake of Hurricane Harvey

Democrats on the House floor pointed out that Republicans refused to pass a $50.5bn disaster relief package in the aftermath of the 2012 Superstorm Sandy, which ravaged north-east states, because it was not offset by budget savings elsewhere.

The north-east states that were hit hardest by Sandy are predominantly Democratic while Texas and much of the southern US leans Republican.

The relief package comes as a more powerful storm, Hurricane Irma, barrels toward Puerto Rico and Florida and threatens more damage.

Mr Trump's deal with the Democrats means that the Republican-controlled Congress will have to address partisan issues such as healthcare and immigration later in the year while negotiating with Democrats over a debt vote.

"Given Republican difficulty in finding the votes for their plan, we believe this proposal offers a bipartisan path forward to ensure prompt delivery of Harvey aid as well as avoiding a default, while both sides work together to address government funding, DREAMERS, and healthcare," Mr Schumer and Mrs Pelosi said.