Local elections across Sri Lanka on Saturday were supposed to be about small issues, like installing street lighting for some neighborhoods and improving garbage sweeping in others.

But the country’s first post-war national government has stagnated, with the governing coalition partners at each other’s throats. Suddenly, the local vote has become a referendum on the national government’s performance.

And, to an extent, the results of the elections may signal what direction the island nation takes in its still-fragile transition from decades of a civil war that killed as many as 100,000 people before it ended in 2009.

The results trickling in on Sunday made it clear that opposition party candidates, led by the former president Mahinda Rajapaksa, were close to sweeping the local councils. They put Mr. Rajapaksa — a former strongman accused of human rights abuses and corruption who brutally crushed the Tamil insurgency before the war ended — once again at the center of the country’s political future.

Mr. Rajapaksa, speaking from his hometown, Tangalle, congratulated his supporters and asked them to celebrate their victory peacefully. Some members of his party went so far as to say that the “people have abolished the mandate” of the governing coalition and called on the government to resign.

“The victory is a clear indication that Sri Lankans are fed up of inaction and want to rebuild Sri Lanka,” Mr. Rajapaksa said on his Facebook page.

Analysts warned that a resounding victory by Mr. Rajapaksa’s party — the Sri Lanka Podujana Peramuna (the Sri Lanka People’s Front, or S.L.P.P.) — would have broader consequences than simply weakening the government of President Maithripala Sirisena, which has two years left.

Mr. Sirisena came to power in 2015 with the help of an unlikely coalition of minority groups and as the face of Sri Lankans’ hope that power would be decentralized, the military and corruption would be reined in, and some of the country’s wounds from the long war would be healed.

But he has not delivered on his promises. And now, critics say, his party’s apparently miserable performance in the local elections — against opponents accused of corruption and abuse — means that the president has missed his chance to carry out his reform agenda.

“This election has made it clear that that window has been closed,” said Jayadeva Uyangoda, former head of the political science department of the University of Colombo. “It’s very difficult to open that window again.”

Mr. Sirisena has led an uneasy coalition government, which he established with Prime Minister Ranil Wickremasinghe’s United National Party in 2015. As the local elections neared, the differences between the two leaders spilled out into the open, with the president frequently attacking United and accusing it of holding back his agenda.

That bickering ended up helping Mr. Rajapaksa, who had never stopped mobilizing in the wings.

“Over the past two years, the coalition government did not do anything significantly new,” Mr. Uyangoda said.

“They had very open disunity, and particularly during the last month of the election campaign, the signal they sent was that this is a government of chaos,” he said. “Obviously, the people then want a strong government. And Rajapaksa is the candidate for a strong ruler, for the stability of governance.”

While the voting on Saturday went smoothly in a country that has experienced violent elections, the Election Commission was slow to release results, as parties demanded recounts in many localities.

The results released so far, and information broadcast by the local news media, suggested that out of 341 local councils total, Mr. Rajapaksa’s S.L.P.P. won 225, the United National Party won 41, and Mr. Sirisena’s Sri Lanka Freedom Party, or S.L.F.P., along with smaller allies, got 14.

For the first time in the country’s history, Sri Lanka required parties to field at least 25 percent female candidates in the elections, hoping the quota would increase the number of women on local councils, where they hold just 2 percent of seats.

Although the impact of the quota was not immediately clear, some neighborhoods reported increased victories by women. Colombo, the capital city, was expected to get its first female mayor after electing Rosy Senanayake, the current deputy head of the prime minister’s office and a former winner of the Mrs. World Pageant.

“It should be 50 percent women, really,” said Dulani Paranawithana, 20, a first-time voter. “But that is difficult to imagine.”

Both governing parties were in soul-searching mode, struggling to figure out their next moves and make changes in time to make sure Mr. Rajapaksa’s party does not ride discontent with the government to victory in the presidential election in 2019. Coalition members were clear that both ruling parties were facing a wave that would be difficult to reverse.

Members of Mr. Sirisena’s team said the president would shake up his cabinet in the coming days.

“This election is a setback, but the majority of Sri Lanka is still anti-Rajapaksa,” said Rajitha Senaratne, Mr. Sirisena’s health minister. “This election has shown that despite everything, the January 8, 2015, coalition, which changed the political culture in this country and ousted the Rajapaksa regime, has remained intact.”

Mr. Seanartne said the election results showed that the combined votes of all other parties, which essentially joined hands in 2015 to defeat Mr. Rajapaksa, were still more than Mr. Rajapaksa’s party’s.

But it was not clear how Mr. Sirisena, long seen a political survivor, could emerge from this political bind.

For decades, he and Mr. Rajapaksa were both S.L.F.P. loyalists, and Mr. Sirisena served as the party’s general secretary for 13 years. In 2015, Mr. Sirisena left the party to run against his own incumbent leader, projecting himself as a unifier above party politics, but soon after becoming president, he took over the party leadership, as well.

Mr. Rajapaska’s wing of the party then formed a new party, the S.L.P.P. In hopes of peeling away some of Mr. Rajapaksa’s support, Mr. Sirisena has backtracked on his own promises of fighting corruption and reining in the military.

To many observers, Saturday’s elections showed that not only had Mr. Sirisena failed to make a dent in Mr. Rajapaksa’s support base, but his confused signals had cost him much of his own.