MEXICO CITY — In his first two years in office, El Salvador’s president marched soldiers into the country’s legislature, defied Supreme Court rulings, published photos of barely clothed gang members crammed together on a prison floor, and dispatched the military to detain anyone breaking quarantine.

Salvadorans can’t get enough of him. President Nayib Bukele, who enjoys an approval rating around 90 percent in polls, is expected to expand his mandate even further in legislative elections on Sunday that could deliver a decisive victory to his party.

The vote could also endow Mr. Bukele with sweeping new powers: control over a legislature that has been dominated by the opposition, along with the chance to begin changing the Constitution and, possibly, to remake the government in his image. If his party and its allies win two-thirds of the seats, they can replace the attorney general and appoint new Supreme Court justices.

In an interview, Mr. Bukele’s vice president, Felix Ulloa, acknowledged that some of the president’s actions have been questionable.

“The president has had some outbursts,” Mr. Ulloa conceded, “but they should be understood as such, as outbursts, as errors, and not as a trend, as an attitude, as the birth of a new dictatorship.”

Mr. Bukele’s tendency toward confrontation will be tempered, Mr. Ulloa said, once he has a legislature that isn’t determined to block his agenda. He invited the world to take measure of the president based on how he governs after the election.

“We will be able to evaluate the true character of this government, whether it’s a democratic government serving the interests of the Salvadoran people,” Mr. Ulloa said. “If, on the contrary, it turns out that the president is, as has been claimed, an authoritarian who wants to concentrate power and impose an antidemocratic model, then that will also come to light.”

Part of what has drawn attention to Mr. Bukele is his approach, which can only be described as very online. A 39-year-old self-styled political outsider, the president delights followers by trolling his enemies on Twitter and reveling in his triumphs on TikTok. He uses social media to trash El Salvador’s press, attack the attorney general and declare his refusal to abide by Supreme Court rulings.

And while Mr. Bukele has helped El Salvador control the spread of the coronavirus better than many of its neighbors, he has drawn international condemnation from human rights groups for his strongman displays and the repressive measures taken during the pandemic.

Last year, he sent soldiers into the legislature to try to pressure lawmakers to approve a loan to finance law enforcement. (Vice President Ulloa called the deployment “an error.”)

Mr. Bukele also dispatched soldiers and the police to detain people breaking quarantine in so-called containment centers — then ignored several Supreme Court orders to halt the practice. And he has drawn widespread criticism for posting photos of prisoners huddled together in their underwear.

Critics worry that if he gains unfettered control over the country after Sunday’s election, he’ll show even less restraint.

“The fear is that he will concentrate the powers of the state. There won’t be real judicial or legislative independence, and there won’t be a way of limiting his power” said Mari Carmen Aponte, an ambassador to El Salvador in the Obama administration.

Mr. Bukele’s relationship with the Biden administration did not get off to a smooth start. The Associated Press reported in February that the Salvadoran president flew to Washington and asked to meet with members of the administration, but was rebuffed.

The awkward episode highlighted the test that Mr. Biden’s victory has posed for leaders like Mr. Bukele.

Under the Trump administration, managing relations with the United States was straightforward: As long as Mr. Bukele and his counterparts in Central America enforced Mr. Trump’s immigration agenda, they could expect little interference from their northern neighbor when they made provocative moves at home.

The White House’s new occupants have sent a far different message. Days after the inauguration, Juan Gonzalez, Biden’s top adviser on Latin America, offered a blunt assessment in an interview with El Faro, a Salvadoran news site.

“We are going to have our differences with Bukele’s government,” Mr. Gonzalez said. “And we’re going to voice worries in a respectful and well-meaning manner.”

Apprehension over Mr. Bukele has reverberated in Washington as it has become clear just how well his party could perform in Sunday’s elections.

“Here’s a guy who hasn’t observed basic democratic norms, and you hand him unchecked power,” the former Obama adviser Dan Restrepo said in an interview. “Unchecked power seldom ends well in the region, and instability can only increase migratory pressure, which is in no one’s interest.”

For Salvadorans accustomed to generations of political leaders who paid lip service to democracy while enriching themselves from the public till, Mr. Bukele’s transgressions don’t seem to matter much.

The president has avoided an overflow of coronavirus cases in hospitals and has handed out cash to poor Salvadorans to blunt the pain of the economic crisis. And while local news media reported that a sharp plunge in murders under Mr. Bukele resulted from a government deal with criminal gangs, many Salvadorans are just happy to have a respite from violence.

“People may write about the dangers of Bukele, but the reason it doesn’t resonate with people is that they say, ‘That feeds me how? That lowers the crime rate how?’” said Tim Muth, who has served as an election observer in El Salvador and writes a blog on the country’s politics.

“The Salvadoran public ultimately may be deciding that it’s OK,” he added, “because this guy is delivering a certain set of things to us.”

In Chalatenango, a small town north of the capital, Bukele’s supporters were giddy at the prospect of their president consolidating power and by the decline of the political parties that had ruled the country for decades.

“The people woke up and realized what we had been living through all these years. No more. We want change,” said Armando Gil, 59, a car salesman.

Mr. Gil had been a longtime supporter of the leftist Farabundo Martí National Liberation Front, but grew disgusted at repeated corruption scandals involving “people who cheated us.”

He voted for Mr. Bukele in 2019 and believes the president’s opponents are frustrated that they can’t control him.

“He isn’t working for the small minority that has always run and dominated our country,” Mr. Gil said. “That’s what they don’t like.”

Nelson Renteria Meza contributed reporting from Chalatenango, El Salvador.