Sri Lanka's prime minister -- a hard-liner toward the Tamil Tiger rebels -- won Sri Lanka's presidential election by a narrow margin, an election official said Friday, after grenade attacks and intimidation kept many minority Tamils from the polls.

With all ballots counted, Rajapakse received 50 percent of the vote, said A.D. de Silva, a member of the Election Commission. Opposition leader Ranil Wickremasinghe received 48 percent. Eleven other candidates split the remaining ballots. A formal announcement of the results was scheduled for later Friday.

Balloting was smooth Thursday in western and southern parts of the island nation and overall turnout was slightly less than 10 million, or about 75 percent, election officials said.

But violence erupted Friday in Akkaraipattu, 140 miles east of Colombo, the capital, as suspected rebels tossed grenades into a mosque during morning prayers, killing at least four worshipers and wounding 10, police said. There were no other immediate details of the attack, and it was not known whether it was linked to the voting.

During the election Thursday, in the north and east -- territory of the feared Tigers -- grenade attacks, roadblocks and fear kept many Tamils from voting. Others heeded a boycott called by pro-rebel groups that complained neither of the main candidates would help them win a homeland in northeastern Sri Lanka.

The Tamils, whose plight is at the heart of a civil war that has lasted more than two decades, make up just under 20 percent of Sri Lanka's 19 million people but were potential kingmakers in the tightly contested election.

The race pitted the hard-line prime minister, Rajapakse, against the dovish opposition leader, Wickremasinghe, whose softer line on peace talks with the rebels won him wide support among Tamils, a largely Hindu minority. The outgoing president, Chandrika Kumaratunga, did not run because of a constitutional two-term limit.

No polling stations were set up in Tiger strongholds because of security concerns, but the government set up special voting booths on the edge of insurgent territory to accommodate the more than 200,000 voters who live behind rebel lines. Officials said roadblocks and intimidation had kept most from making it out of rebel territory to vote.

In and around Jaffna, a northern city controlled by the government but heavily populated by Tamil Tigers, officials said turnout was less than 1 percent.

Grenade blasts forced European Union observers to pull out of the eastern city of Batticaloa, the scene of frequent clashes between the Tigers and breakaway rebel factions. At least two people were killed in the attacks.

The Tigers took up arms in 1983 over discrimination against Tamils by the predominantly Buddhist Sinhalese majority. Nearly 65,000 people have been killed in the conflict. A 2002 cease-fire ended the worst of the fighting, but peace talks stalled over the Tigers' demands for broad autonomy, and clashes have intensified.

At left, policemen escort election workers and their ballot boxes to a counting center in the Sri Lankan capital, Colombo, after the presidential election. Above, villagers in an area controlled by the Tamil Tiger rebels turn back at a roadblock in eastern Sri Lanka.