Kaczynski, head of the Law and Justice party (PiS), had conceded defeat when exit polls had indicated a Komorowski victory, although hours later he briefly nudged ahead of his rival in the count.
But as results rolled in from bigger cities, mostly PO strongholds, Komorowski regained the lead.
"Tonight we open a small bottle of champagne and tomorrow we will open a big bottle," Komorowski told jubilant party members in Warsaw after his victory became clear on Sunday.
"We thank everybody - the more so that it was an unusual campaign, a difficult campaign held in the shadow of catastrophe."
An election was originally set for the autumn but had to be called early after April's air crash killed Lech Kaczynski and many other senior officials.
The worst tragedy to strike Poland in decades set the tone for an election campaign largely free of the political manoeuvring that often precedes the country's elections.
After conceding defeat, Kaczynski paid tribute to his twin brother.
"I would like to mention here the man, the people who are the reason for our being here: my brother and all those killed in the Smolensk catastrophe," he said.
"Let us remember them because this result grew out of their martyr-like deaths. A new quality grew out of my brother's work and service, a return to values, a return to patriotism."
Both presidential candidates were former anti-communist activists with conservative, Roman Catholic upbringings, but they split on crucial issues, primarily the role of the state in the economy.
The vote will help decide the speed and scale of economic overhaul and set the tone for Poland's ties with its European Union partners and with Russia.
Komorowski is expected to smooth the way for the government to continue privatising state-run companies and cut welfare benefits, if the exit poll results are upheld.
In Poland, the government led by the prime minister sets policy, but the president appoints many senior officials, has a say in foreign and security policy, and can propose and veto laws.
Lech Kaczynski had vetoed several government bills before his death and Donald Tusk, the prime minister who is from Komorowski's PO party, signalled late on Sunday that some public spending cuts may now be in the pipeline.
"From Monday we need to start working harder than in the past," Tusk told reporters.
"We want to spend money in a reasonable way and this will require the support of politicians and citizens. I will ask my political partners and the parliament to help impose some discipline in our public finances," he said.
Having Komorowski and Tusk coming from the same party could lead to increased stability, Igor Janke, a Polish journalist and columnist, said.
"The two most important people are coming from the same party, they will cooperate much better than our prime minister had cooperated with the previous president," Janke told Al Jazeera.
Pawel Poncyljusz, a leading member of Kaczynski's Law and Justice party, said that Komorowski's victory would put pressure on PO to make the changes to public finances it had been pushing for.
"If the prognosis is confirmed, it will be a dubious victory for Civic Platform because then they will not be able to say that the opposition is hampering their work," he said.
The European Union's largest former communist member is the only economy in the 27-strong bloc to have avoided recession last year, but a sharp slowdown has hammered tax revenues and driven up the budget deficit to seven per cent of gross domestic product.
Public debt, though low by Western European standards, is creeping towards the 55 per cent of GDP threshold which, if breached, would by law trigger painful spending cuts.
Despite overcoming the risk of a presidential veto, PO faces other hurdles in the way of reforms, as it is locked in a coalition with the small Peasants' party opposed to any attack on the pension privileges of farmers and other occupational groups.
Komorowski, 58, will be Poland's fourth democratically elected president since the fall of communism 1989.
Two predecessors, Lech Walesa and Aleksander Kwasniewski, had both backed his bid.
|Kaczynski said his good result boded well for next year's parliamentary polls [Reuters]
As speaker of Poland's lower house of parliament and second ranking official in the state hierarchy, he had automatically become acting president on Lech Kaczynski's death.
His election to a five-year term will be welcomed in other EU capitals and in Moscow because Komorowski backs Tusk's efforts to improve foreign ties that came under strain during Jaroslaw Kaczynski's short stint as prime minister between 2006 and 2007.
Tusk, who has fostered strong ties with Angela Merkel, the German chancellor, also wants to take Poland into the eurozone as soon as possible, though given the bloc's recent woes, that is now unlikely to happen before 2015.
And while Kaczynski congratulated his rival, he also told supporters that his good result in the election boded well for local elections in the autumn and next year's parliamentary polls.
"We have to win them and we will," he said.