"The prime minister, under the election act... is duly elected as president of Sri Lanka," said elections commissioner Dayananda Dissanayake.
Rajapakse won the presidency with 50.3 percent of the popular vote, according to the results.
He will be sworn at a ceremony at the colonial-style Presidential Secretariat overlooking the Indian Ocean on Saturday by Chief Justice Sarath Silva.
Rajapakse is expected to name a prime minister and a new cabinet, possibly as early as Saturday.
News that the left-leaning prime minister had narrowly won saw the benchmark All Share Price index plunge 176 points, or seven percent -- the worst opening fall in two years.
It lost another three points during the day's trading to close at 2,325.
Former air force chief Harry Gunatillake said the markets went into a spin because the victory of the hawkish Rajapakse meant that the peace process with Tamil Tiger rebels could not be revived immediately.
"We won't see the new president in a position to start the peace talks soon because the nationalists who support him will not allow him to make any concession," Gunatillake said.
He said Sri Lanka's peace broker Norway will also find it difficult to get used to the new dispensation in Colombo and the "getting to know" period would mean further delays.
Sri Lanka is under pressure from the international community to revive peace talks that have been suspended since April 2003, in order to qualify for billions of dollars in aid to rebuild tsunami-ravaged coastlines.
Markets were first to react to what they saw as bad news.
"Everybody's dumping -- there are net sellers in the market today following early election results," said Vajira Premawardhana, head of research at LOLC Securities.
Rajapakse is an outspoken opponent of privatisation and supports a leftist, state-dominated economy. Wickremesinghe campaigned for market reforms in a bid to woo more foreign investment.
Violence, meanwhile, continued to plague the country's east, with unidentified attackers lobbing grenades into a mosque during early Friday prayers. They killed four men at prayer and wounded at least 25 others, police said.
The grenade blasts ripped through the mosque at the town of Akkaraipattu in the district of Ampara.
Police said that during Thursday's vote, two Tamil Tiger rebels and a Sinhalese civilian died and 17 people were wounded in a string of seven bomb and grenade attacks in the east.
Private poll monitors said Tamil Tiger rebels had effectively forced a boycott of the vote and prevented Tamils, who make up 12.6 percent of the population, from taking part.
There was virtually no voting in the embattled northern region while voting was low in the volatile eastern province, but the overall national average of polling was about 75 percent, Dissanayake said.
The vote chief made no reference to an appeal by Wickremesinghe's United National Party calling for a fresh poll on grounds that the blocking of voting by some 700,000 people in Jaffna may have robbed them of victory.
Fewer than 0.01 percent of the electorate turned out to vote in Jaffna after the rebel Liberation Tigers of Tamil Eelam said they were not interested in either of the two main candidates.
The rebels made no comment on the polling or the result.
The Tigers had branded the movie star-turned-prime minister the "war candidate" after he called for a full review of a Norwegian-backed peace process.
With the declaration of the final result, President Chandrika Kumaratunga's second and last term comes to an end. She can remain in office until Rajapakse takes over within two weeks. - AFP
-Amal Jayasinghe: email@example.com