President Trump on Thursday signed a $19.1 billion disaster aid bill that languished for months in Congress amid competing demands for border wall funding and aid for hurricane-ravaged Puerto Rico.

Trump tweeted a photo of himself holding the signed bill in what appeared to his office on Air Force One. The tweet came shortly after he'd landed in Ireland following a ceremony in France commemorating the D-Day invasion.

Trump said the aid, which will benefit states including Georgia and Florida, is "so important for our GREAT American farmers and ranchers."

Trump also tweeted that Puerto Rico "should love President Trump," claiming that "without me, they would have been shut out!"

The House on Monday gave the measure final congressional approval by a 354-58 vote in the House's first significant action after returning from a 10-day recess. It was backed by all 222 voting Democrats and 132 Republicans, including the GOP's top leaders and many of its legislators from areas hit by hurricanes, floods, tornadoes and fires. Fifty-eight Republicans voted "no," including many of the party's most conservative members.

Conservative Republicans in the House held up the bill last week, objecting on three occasions to efforts by Democratic leaders to pass the bill by a voice vote requiring unanimity. They said the legislation — which reflects an increasingly permissive attitude in Washington on spending to address disasters that sooner or later hit every region — shouldn't be rushed through without a recorded vote.

The measure was initially held up over a fight between Trump and Democrats over aid to Puerto Rico.

SAN JUAN MAYOR SUGGESTS TRUMP 'VINDICTIVE' TOWARD PUERTO RICO BECAUSE HIS GOLF COUSE THERE 'WENT BANKRUPT'

"Some in our government refused to assist our fellow Americans in Puerto Rico who are still recovering from a 2017 hurricane. I'm pleased we've moved past that," said House Appropriations Committee Chairwoman Nita Lowey, D-N.Y. "Because when disaster strikes, we shouldn't let a ZIP code dictate our response."

The measure also faced delays amid failed talks on Trump's $4 billion-plus request to care for thousands of mostly Central American migrants being held at the southern border. The sides narrowed their differences but couldn't reach agreement in the rush to go on recess, but everyone agrees that another bill will be needed almost immediately to refill nearly empty agency accounts to care for migrants.

"We must work together quickly to pass a bill that addresses the surge of unaccompanied children crossing the border and provides law enforcement agencies with the funding they need," said top Appropriations Committee Republican Kay Granger of Texas. "The stakes are high. There are serious — life-or-death — repercussions if the Congress does not act."

The measure is largely the same as a version that passed the House last month. Republicans opposed it for leaving out the border funding. Among the reasons was a demand by House liberals to block the Homeland Security Department from getting information from federal social welfare authorities to help track immigrants residing in the U.S. illegally who take migrant refugee children into their homes. As the measure languished, disasters kept coming — with failed levees in Arkansas, Iowa and Missouri and tornadoes across Ohio just the most recent examples.

CLICK HERE TO GET THE FOX NEWS APP

The measure is supported by the bipartisan leadership in both the House and the Senate. The legislation is also being driven by Florida and Georgia lawmakers steaming with frustration over delays in delivering help to farmers, towns and military bases slammed by hurricanes last fall. Flooding in Iowa and Nebraska this spring added to the coalition behind the measure, which delivers much of its help to regions where Trump supporters dominate.

The bill started out as a modest $7.8 billion measure passed in the last days of House GOP control. A $14 billion version advanced in the Democrat-led chamber in January and ballooned to $19.1 billion by the time it emerged from the floor last month, fed by new funding for community rehabilitation projects, Army Corps of Engineers water and flood protection projects and rebuilding funds for several military bases, including Offutt Air Force Base in Nebraska.

Many Republicans opposed funding to mitigate future disasters as part of rebuilding projects when Superstorm Sandy funding passed in 2013, only to embrace it now that areas such as suburban Houston need it. Democrats, for their part, held firm for what ended up as roughly $1.4 billion for Puerto Rico, letting Trump feud with the U.S. territory's Democratic officials for weeks and deflecting political blame for stalling the bill.

The Associated Press contributed to this report.