EL SALVADOR’S president, Nayib Bukele, imposed some of the earliest and toughest measures in the Americas to prevent the spread of the novel coronavirus, with some success: As of Friday midday, the nation of 6 million had recorded 424 cases and 10 deaths from covid-19, fewer than most of its Central American neighbors. But recent events suggest the principal interest of the populist president is not protecting Salvadorans from illness; it’s consolidating his personal power at the expense of the country’s fragile democracy.

Shocking evidence of that came on Sunday, when Mr. Bukele’s office released photos showing prisoners crammed head-to-back while their cells were searched — at the obvious risk of spreading the coronavirus among them. Following the operation, the prisoners were locked down in crowded cells, and Mr. Bukele bragged that members of rival gangs had been mixed together and their quarters sealed so they “will no longer be able to see outside the cell.” He also announced a roundup of gang members outside prison and said anyone “who resists will be put down with proportional and possibly lethal force by our security forces.”

Mr. Bukele was evidently incensed by a burst of 77 murders over last weekend, a sharp break with what had been months of relative peace in one of the world’s most violent countries. He blamed the killings on El Salvador’s powerful gangs and said they had been ordered by imprisoned leaders. Yet as human rights groups were quick to point out, his harsh response was inhumane and probably violated both Salvadoran and international law.

Unfortunately, Mr. Bukele no longer respects legal boundaries. After ordering Salvadorans to remain in their homes last month, he decreed that those found in the streets without a valid cause would be detained in “quarantine centers.” Thousands are being held in the facilities without due process or regard for whether they are carrying the virus. After the constitutional court ruled that the arrests were improper, Mr. Bukele defiantly tweeted that he wouldn’t respect the decision.

The court told the National Assembly to pass a quarantine law that preserved constitutional rights. But as legislators moved to do so on April 23, immediately after overriding a presidential veto of aid for health workers, Mr. Bukele forced them to suspend their session by claiming that health authorities had detected the coronavirus inside the assembly building.

The following day — we suspect not by coincidence — Mr. Bukele managed to score a phone call and a friendly tweet from President Trump, who said the Bukele government has “worked well with us on immigration on the southern border.” The message to Salvadorans was clear: The Trump administration will ignore the president’s authoritarian behavior so long as he cooperates — as he has — with the White House’s draconian steps to prevent Central Americans from crossing the southern border.

The United States invested many years and billions of dollars in fostering democracy in El Salvador during and after its bloody civil war. It would be a tragedy if Mr. Trump allowed Mr. Bukele to undo that achievement on the pretext of fighting gangs and the pandemic. The result would surely be more of the migration that Mr. Trump is so intent on preventing.

Read more: