Residents of San Juan had strong words after President Trump tweeted on Oct. 12 that relief workers would not stay in Puerto Rico "forever." (Hector Santos Guia,Patrick Martin/The Washington Post)

President Trump served notice Thursday that he may pull back federal relief workers from Puerto Rico, effectively threatening to abandon the U.S. territory amid a staggering humanitarian crisis in the aftermath of Hurricane Maria.

Declaring the U.S. territory's electrical grid and infrastructure to have been a “disaster before hurricanes,” Trump wrote Thursday that it will be up to Congress how much federal money to appropriate to the island for its recovery efforts and that relief workers will not stay “forever.”

Three weeks after Maria made landfall, much of Puerto Rico, an island of 3.4 million people, remains without power. Residents struggle to find clean water, hospitals are running short on medicine, and commerce is slow, with many businesses closed.

[Trump’s tweets anger, but do not surprise, Puerto Ricans]

Trump on Thursday sought to shame the territory for its own plight. He tweeted, “Electric and all infrastructure was disaster before hurricanes.” And he quoted Sharyl Attkisson, a television journalist, as saying, “Puerto Rico survived the Hurricanes, now a financial crisis looms largely of their own making.”

He also wrote: “We cannot keep FEMA, the Military & the First Responders, who have been amazing (under the most difficult circumstances) in P.R. forever!”

Puerto Rico Gov. Ricardo Rosselló responded with his own tweet, saying Puerto Ricans were seeking the support “any of our fellow citizens would receive across our Nation.”

Carmen Yulín Cruz, the mayor of the capital city, San Juan, who has been feuding publicly with Trump, strongly condemned the president Thursday in a tweet calling him a "Hater in Chief" and in a lengthy statement sent to reporters and members of Congress. She said the president's actions "are unbecoming of a leader of the free world," and she argued that he "is simply incapable of understanding the contributions, the sacrifices and the commitment to democratic values that Puerto Ricans have shown over decades."

Cruz pleaded with "every American that has love, and not hate in their hearts, to stand with Puerto Rico and let this President know we WILL NOT BE LEFT TO DIE."

The White House issued a statement Thursday committing for now "the full force of the U.S. government" to the Puerto Rico recovery, though noting that "successful recoveries do not last forever."

“Our job in any disaster affected location is to help the community respond and recover from that disaster," White House press secretary Sarah Huckabee Sanders said. "We continue to do so with the full force of the U.S. government and its resources in Texas, Florida, Puerto Rico and the U.S. Virgin Islands and other affected areas. Successful recoveries do not last forever; they should be as swift as possible to help people resume their normal lives. We are committed to helping Puerto Rico. Our administration is working with Governor Rosselló and Congress to identify the best fiscally responsible path forward.”

Trump has been roundly criticized for his leadership in coming to Puerto Rico's aid. In response, the president has tried to portray the territory as in full recovery mode and has voiced frustration with what he considers mismanagement by local officials.

During a visit last week, the president tossed rolls of paper towels at local residents as if shooting baskets, drawing scorn from local leaders. He also complained that the recovery efforts had “thrown our budget a little out of whack,” and noted that the death toll was lower than the “real catastrophe” of Hurricane Katrina, which devastated New Orleans and surrounding areas in 2005.

Trump's threats to limit the emergency worker footprint in Puerto Rico come as the House is set to vote Thursday on a $36.5 billion disaster aid package that includes provisions to avert a potential cash crisis in Puerto Rico prompted by Hurricane Maria.

Analysis | After Hurricane Maria, much of Puerto Rico is still in the dark

Rosselló warned congressional leaders over the weekend that the U.S. territory is “on the brink of a massive liquidity crisis that will intensify in the immediate future.” The legislation set for a vote allows up to $4.9 billion in direct loans to local governments in a bid to ease Puerto Rico’s financial crunch.

Without congressional action, the territory may not be able to make its payroll or pay vendors by the end of the month.

House Speaker Paul D. Ryan (R-Wis.) said that Puerto Rico must eventually "stand on its own two feet," but that the federal government needs to continue to respond to the humanitarian crisis.

"We're in the midst of a humanitarian crisis," Ryan said. He added, "Yes, we need to make sure that Puerto Rico can begin to stand on its own two feet. … But at the moment there is a humanitarian crisis has to be attended to and this is an area where the federal government has a responsibility, and we're acting on it."

Top Democrats assailed Trump for his Thursday tweets on Puerto Rico. House Minority Leader Nancy Pelosi (D-Calif.) called Trump's tweets "heartbreaking," adding that "we are all Americans, and we owe them what they need."

Senate Minority Leader Charles E. Schumer (D-N.Y.) tweeted: “There is still devastation, Americans are still dying. FEMA needs to stay until the job is done.”

Another New York Democrat, Rep. Nydia M. Velázquez, who was born in Puerto Rico, said in a statement that the president's “most solemn duty is to protect the safety and the security of the American people. By suggesting he might abdicate this responsibility for our fellow citizens in Puerto Rico, Mr. Trump has called into question his ability to lead. We will not allow the federal government to abandon Puerto Rico in its time of need.”

Jennifer Hing, a spokeswoman for House Appropriations Committee Chairman Rodney Frelinghuysen (R-N.J.), said that those who live on the island “are American citizens and they deserve the federal assistance they need to recover and rebuild. The Chairman and the Committee fully stand by them in these efforts, and will continue to be at the ready to provide the victims of these devastating hurricanes with the necessary federal resources both now and in the future.”

Frelinghuysen is scheduled to be part of a delegation led by House Speaker Paul D. Ryan (R-Wis.) that will visit Puerto Rico on Friday to see the hurricane’s devastation firsthand.

The president's tweets on Thursday seemed to contradict Vice President Pence, who during a visit to the island last week vowed that the administration would be with Puerto Rico “every step of the way.”

“I say to all of you gathered here today to the people of Puerto Rico:  We are with you, we stand with you, and we will be with you every single day until Puerto Rico is restored bigger and better than ever before,” he said.

Trump himself made a similar promise, saying in a Sept. 29 speech, “We will not rest, however, until the people of Puerto Rico are safe.” He added: “These are great people. We want them to be safe and sound and secure. And we will be there every day until that happens.”

Arelis R. Hernández in Puerto Rico and Mike DeBonis in Washington contributed to this report.