WASHINGTON — President Trump sought to reassure Puerto Rico on Friday that he was not abandoning the hurricane-ravaged island, shifting his message a day after blaming its leadership for the territory’s ongoing crisis and warning that he "cannot keep” federal troops and emergency workers “in P.R. forever.”

In a morning posting on Twitter, Mr. Trump stuck to his position that Puerto Rico was already deeply troubled before Hurricanes Irma and Maria hit, but he cast the point in a tone of greater solidarity. “The wonderful people of Puerto Rico, with their unmatched spirit, know how bad things were before the H’s,” he wrote. “I will always be with them!”

He repeated that sentiment in a speech later in the morning. “These are people that are incredible people,” he said, referring to residents of Puerto Rico as well as other places hit by recent storms. “They’ve suffered greatly and we’ll be there. We’re going to be there. We have, really — it’s not even a question of a choice. We don’t even want a choice. We’re going to be there as Americans and we love those people and what they’ve gone through.”

Mr. Trump used his speech to a gathering called the Values Voter Summit to reinforce his alliance with religious conservatives who have backed his candidacy and presidency. Noting that he was the first sitting president to address the conference, Mr. Trump embraced a more prominent role for religion in politics and public life and vowed to stop “the attacks on Judeo-Christian values.”