Lawyer Natasa Pirc Musar will become Slovenia's first female head of state after winning the second round of the presidential election
Pirc Musar, 54, won 53.83 per cent of votes in the runoff, while her rival, right-wing politician and former foreign minister Andze Logar, won 46.17 per cent, according to election commission data based on 99 per cent the votes counted.
Turnout was 49.9 per cent, the commission data showed.
"I will do my best to be a true president for all, to work for fundamental and constitutional human and democratic rights and democracy," Pirc Musar told reporters after claiming victory.
Although the role is mostly ceremonial, the president is commander in chief of the armed forces and nominates several top officials, including the central bank governor.
Most of the nominations have to be confirmed by parliament.
The new president of Slovenia, a European Union and NATO member state, replaces Borut Pahor who has been active in politics for 30 years.
A former fashion model who served two five-year terms, Pahor is often referred to in public as the Instagram president for his frequent use of the social network.
"I expect the next president to care about us, the citizens, to represent Slovenia in a good manner," Uros Pinter said after casting his ballot in Ljubljana.
"I think it is time for a female president."
Pirc Musar, a former TV presenter who became an influential lawyer, campaigned on human rights, the rule of law and social welfare issues.
Her rival Logar, 46, is a member of the right-wing Slovenian Democratic Party (SDS) of former prime minister Janez Jansa, who lost April's parliamentary election to the environmentalist Freedom Movement of Robert Golub.
Commenting on the outcome of Sunday's presidential election, Golub told reporters: "I am confident that we will work well together to address the common challenges of the future."