Opposition challenger Kolinda Grabar-Kitarovic has become the first female president of Croatia, winning by the narrowest of margins.
She secured 50.5% of the vote with 99% of ballots counted, while incumbent Ivo Josipovic was close behind on 49.5%.
Mr. Josipovic has conceded defeat and congratulated his opponent.
The challenger’s win is a sign that Croatia may be shifting to the right after the centre-left coalition’s failure to end six years of downturn.
The election was seen as a key test for the main parties ahead of parliamentary elections expected to be held towards the end of 2015.
The gap between the two candidates remained at about one percentage point throughout much of the second round.
Turnout was 58.9% – some 12% more than in the first round held two weeks ago, which was equally close.
Ms. Grabar-Kitarovic is a politically conservative member of the Croatian Democratic Union (HDZ), which pushed the country towards independence from the former Yugoslavia in 1991.
The 46-year-old is a former foreign minister and assistant to the Nato secretary general.
“I will not let anyone tell me that Croatia will not be prosperous and wealthy,” she told jubilant supporters in the capital Zagreb, calling for national unity to tackle the economic crisis.
Mr. Josipovic, a 57-year-old law expert and classical composer, had been president since 2010.
Mr. Josipovic had been so popular for so long that it seemed impossible he could fail in a bid for re-election.
His problem was that he was backed by the governing, centre-left coalition that has failed to pull Croatia out of a six-year-long recession.
Prime Minister Zoran Milanovic apologised for being a “burden” to the outgoing president. His government may also pay the price in elections later this year, our correspondent adds.
Croatia, which became the newest member of the European Union when it joined in July 2013, has an unemployment rate close to 20%.
The Croatian president has a say in foreign policy and is head of the army, but running the country is primarily left to the government.
Mr. Josipovic proposed constitutional changes in a bid to solve the economic crisis – including increased powers for the president.