Soldiers have surrounded the hotel where Gen Sarath Fonseka is staying
President Mahinda Rajapaksa has won Sri Lanka's first election since Tamil Tiger rebels were defeated after 25 years of civil war, state TV reports.
Although the final results are yet to be declared, Mr Rajapaksa appears to have won more than half the votes cast.
But his election rival, Gen Sarath Fonseka, has rejected the reported result and said he will challenge it.
About 100 armed troops have surrounded the hotel in the capital, Colombo, where Gen Fonseka is staying.
A government spokesman told the BBC they did not intend to hold Gen Fonseka but were looking for army deserters.
The BBC's Anbarasan Ethirajan, who is in the same hotel as Gen Fonseka and other opposition leaders, says the troops' presence has created a very tense atmosphere.
A military spokesman said their deployment was a "protective measure".
AT THE SCENE
Anbarasan Ethirajan, BBC News, Colombo
I'm now inside the hotel where the main opposition candidate and other opposition leaders are staying. It is surrounded by heavily armed troops and commandos.
There is a tense atmosphere. One of the opposition alliance leaders said it was intimidating and that the alliance has appealed to the government to withdraw the troops.
The opposition leader said he was willing to accept the result of the election as legitimate as they had not seen any large-scale malpractices or rigging on election day.
The military had earlier said they were looking for about 400 army deserters and ex-soldiers staying in the hotel and that they should surrender immediately.
Udaya Nanayakkara said that some 400 people had gathered inside the Cinnamon Lake Hotel in the capital.
"We don't know what is 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," he said.
Gen Fonseka said he feared the troops planned to arrest him if he won the election, a claim denied by officials.
An opposition spokesman, Rauf Hakeem, said opposition members had appealed to the government over what he said were "high-handed tactics" intended to intimidate them.
He told reporters there were no deserters inside the hotel.
With nearly all the results in, Mr Rajapaksa had 5.9 million votes - or 58% of the total - to 3.39 million for his rival, state TV reported.
Some 70% of Sri Lanka's 14 million-strong electorate turned out to vote. However, turnout in the Tamil areas in the north-east, where the fiercest fighting occurred during the conflict, was less than 30%.
Lucien Rajakarunanayake, a spokesman for Mr Rajapaksa, told the Associated Press news agency that the president had "won a historic and resounding victory in the first free and fair elections held throughout the country since the defeat of terrorism".
Supporters of Mr Rajapaksa celebrated in the streets of Colombo, waving Sri Lankan flags and setting off fireworks.
Under Sri Lanka's electoral rules, if no candidate wins 50% of ballots cast in the first count, then voters' second - or even third - preferences are tallied to determine the winner.
The BBC's Charles Haviland, in Colombo, says it is probably only a matter of time before Gen Fonseka's team concedes, but the opposition may raise certain objections as to how the election campaign was conducted.
Independent observers have been perturbed by two main elements, our correspondent says, one of which is the amount of violence in the run-up to the election - with most complaints about the perpetration of violence laid at the door of the president's side.
The other is what monitors say is the misuse of public resources and state media.
State TV in particular gave blanket coverage to Mr Rajapaksa, our correspondent says, with Gen Fonseka more or less a footnote, and public buses were used to ferry around the incumbent's campaign material.
The government has said it paid for the use of buses and other state resources but the independent election monitoring bodies are not convinced, our correspondent says.
After a violent and acrimonious campaign, during which four people died and hundreds were wounded, Tuesday's election was largely peaceful.
But there were serious exceptions, especially in the Tamil-populated north.
In the city of Jaffna, the private Centre for Monitoring Election Violence said there were at least six explosions before and just after voting began.
Later there were two blasts in Vavuniya, the town near the huge camps for people displaced by the war. The organisation said it feared this was a systematic attempt to scare people away from voting.
There were also grenade attacks in the Sinhala-dominated centre and south where the fight between the two candidates has been especially bitter, our correspondent says.
It later turned out that Gen Fonseka had not been able to vote because his name was not on the register.
The two men were closely associated with the defeat of the Tamil Tigers last May but fell out soon afterwards. Gen Fonseka quit the military, complaining that he had been sidelined after the war.
The president's side accuses the general of courting separatists. The general has accused the president of plotting vote-rigging and violence, something his rival denies.
Both main candidates have promised voters costly subsidies and public sector pay rises.
However, economists say this will make it hard for the country to meet cost-cutting obligations imposed under the terms of a $2.6bn (£1.6bn) International Monetary Fund loan.