Veteran centre-right politician and television pundit Marcelo Rebelo de Sousa has won Portugal's presidential elections.
With nearly 99% of the vote counted, the 67-year-old is winning 52% - enough to avoid a run-off.
His closest rival, leftist Antonio Sampaio da Novoa, is polling 22%.
The post of president is mainly ceremonial, but the head of state can dissolve parliament. A shaky left-wing coalition currently governs Portugal.
Observers suspect the coalition may unravel within a year or so, so the new president may end up playing a more active role, the BBC's Alison Roberts reports from Lisbon.
A record 10 candidates took part in Sunday's elections.
A winning contender needs 50% of the vote to avoid a run-off on 14 February.
Mr de Sousa is known as "Professor Marcelo" to his supporters and has been involved in politics since his youth, helping to establish the centre-right Social Democratic Party.
He has the support of right-wing parties but says he will not be reliant on them. He has pledged to do everything he can to ensure the current government's stability.
If elected, he will take over in March from Anibal Cavaco Silva, a conservative who served two consecutive five-year terms.
A centre-right coalition won the most votes in October's election but lost its overall majority in November to be replaced by an alliance of left-wing parties which rejected its austerity programme in parliament.
Portugal was one of the countries hardest hit by the crisis in the eurozone, accepting an international bailout in exchange for sweeping cuts.