The House passed a $36.5 billion aid bill Thursday to help hurricane-hit states and Puerto Rico.

The move comes after President Donald Trump lashed out at hurricane-devastated Puerto Rico on Thursday, insisting in tweets that the federal government can't keep sending help "forever" and suggesting the U.S. territory was to blame for its financial struggles.

His broadsides triggered an outcry from Democrats in Washington and officials on the island, which has been reeling since Hurricane Maria struck three weeks ago, leaving death and destruction in an unparalleled humanitarian crisis.

San Juan Mayor Carmen Yulin Cruz, with whom Trump has had a running war of words, tweeted that the president's comments were "unbecoming" to a commander in chief and "seem more to come from a 'Hater in Chief.'"

"Mr. President, you seem to want to disregard the moral imperative that your administration has been unable to fulfill," the mayor said in a statement.

Forty-five deaths in Puerto Rico have been blamed on Maria, about 85 percent of Puerto Rico residents still lack electricity and the government says it hopes to have electricity restored completely by March.

Both Trump and Vice President Mike Pence visited the island last week to offer the U.S. commitment to the island's recovery. But Trump's tweets on Thursday raised questions about whether the U.S. resolve. He tweeted: "We cannot keep FEMA, the Military & the First Responders, who have been amazing (under the most difficult circumstances) in P.R. forever!"

In a series of tweets, the president added, "electric and all infrastructure was disaster before hurricanes." He blamed Puerto Rico for its looming financial crisis and "a total lack of accountability."

The tweets conflicted with Trump's past statements on Puerto Rico. During an event last week honoring the heritage of Hispanics, for example, the president said, "We will be there all the time to help Puerto Rico recover, restore, rebuild."

Democrats said Trump's attacks were "shameful," given that the 3 million-plus U.S. citizens on Puerto Rico are confronting the kind of hardships that would draw howls of outrage if they affected a state. One-third of the island lacks clean running water and just 8 percent of its roads are passable, according to government statistics.

"It is shameful that President Trump is threatening to abandon these Americans when they most need the federal government's help," said Maryland Rep. Steny Hoyer, the second-ranking House Democrat.

After years of economic challenges, Puerto Rico was already in the process of restructuring much of its $74 billion in debt before the hurricane struck. The financial situation is more complicated than Trump's tweets suggest.

Puerto Rico lost population and jobs after Congress eliminated special tax breaks in 2006, making it more difficult to repay its debts. Yet lenders continued to extend credit to Puerto Rico despite its economic struggles, while pension costs strained Puerto Rico's government and its infrastructure deteriorated.

The legislative aid package totals $36.5 billion and sticks close to a White House request. For now, it ignores huge demands from the powerful Florida and Texas delegations, which together pressed for some $40 billion more.

A steady series of disasters could put 2017 on track to rival Hurricane Katrina and other 2005 storms as the most costly set of disasters ever. Katrina required about $110 billion in emergency appropriations.

The bill combines $18.7 billion for the Federal Emergency Management Agency with $16 billion to permit the financially troubled federal flood insurance program pay an influx of Harvey-related claims. An additional $577 million would pay for western firefighting efforts.

Up to $5 billion of the FEMA money could be used to help local governments remain functional as they endure unsustainable cash shortfalls in the aftermath of Maria, which has choked off revenues and strained resources. Ryan, the House speaker, planned to visit Puerto Rico on Friday. He has promised that the island will get what it needs.

"It's not easy when you're used to living in an American way of life, and then somebody tell you that you're going to be without power for six or eight months," said Resident Commissioner Jenniffer Gonzalez-Colon, who represents Puerto Rico as a nonvoting member of Congress. "It's not easy when you are continue to suffer — see the suffering of the people without food, without water, and actually living in a humanitarian crisis." ___ AP Business writer Josh Boak contributed to this report.