Sri Lankan President Mahinda Rajapaksa won a resounding re-election victory Wednesday, beating back a challenge from his former army chief to lead this nation as it tries to rebuild from a devastating civil war, state television reported.

With nearly all votes counted, Rajapaksa had a 58 percent to 40 percent lead over Sarath Fonseka, state television reported.

Both men were considered war heroes by the Sinhalese majority for their successful offensive to destroy the Tamil Tiger separatists after 25 years of conflict.

But Rajapaksa's powerful political machine — and his alleged use of state resources, especially state media in his campaign — apparently overwhelmed Fonseka's opposition bid to unseat him in the election Tuesday.

Fonseka was also hoping for strong support from ethnic Tamils, who bore the brunt of the government's final offensive against the rebels, but turnout among the minority was dismal.

With overall turnout about 70 percent, state TV said Rajapaksa had secured 5.5 million votes to Fonseka's 3.9 million, with only a few hundred thousand votes outstanding.

There was no immediate reaction from either candidate.

In the hours before the announcement, hundreds of troops surrounded Fonseka's hotel, reflecting the tensions surrounding the race.

Just eight months ago, the men declared victory in the war against the rebels. But a bitter falling out pushed Fonseka to quit, join the opposition and challenge the president.

Throughout the campaign, the opposition accused Rajapaksa of plotting to rig the vote and steal the election. Fonseka himself was unable to vote Tuesday because he was not registered. It was unclear if he had failed to register or if he tried and was left off the voter rolls.

As results were being announced, troops surrounded the Cinnamon Lake Hotel after about 400 people, including alleged army deserters, gathered inside with Fonseka, military spokesman Brig. Udaya Nanayakkara said.

"We don't know what's their motive, and as a protective measure we have deployed troops around the hotel, and people who go in and come out are being checked," Nanayakkara told The Associated Press. He said there were no plans to arrest Fonseka.

Speaking to reporters at the hotel, opposition lawmaker Rauf Hakeem denied deserters were there and called for the government to allow Fonseka freedom of movement.

He said Fonseka had not tried to leave, but that the troop deployment signaled "his leaving the hotel will be quite dangerous."

Jehan Perera, a political analyst in Colombo, called the military presence at the hotel "absolutely unprecedented."

"It reflects the suspicion and the level of mistrust," Perera said.

Attempts to reach Fonseka were not immediately successful.

Fonseka remains popular with the troops he led to victory against the Tamil Tigers, and the government is worried that he might claim electoral fraud and then try to rally his former soldiers, Perera said.

The race has been acrimonious from the start, with the general accusing his former boss of entrenched corruption and the president branding Fonseka a dictator-in-waiting.

No major violence was reported during Tuesday's polling.

While voting among the Sinhalese majority appeared to be strong, turnout was sparse in some northern Tamil areas, where the most intense fighting drove hundreds of thousands from their homes. The minority community had been expected to support Fonseka and play a possibly pivotal role in the results.

Rajapaksa campaigned on his war record and promises to bring development to the nation. Fonseka pledged to trim the powers of the presidency and empower parliament.

Some observers fear that a dispute over the results could lead to street protests and violence.