Peter Bossman, 54, became mayor of the picturesque seaside city of Piran in the second round of local elections after beating the centre-right incumbent, according to preliminary results.
“My victory shows a high level of democracy in Slovenia,” said Mr Bossman, who came to Slovenia from Ghana 33 years ago to study medicine.
He is a member of the Social Democrats, the leading party in the centre-left government.
Mr Bossman had aimed to return to Ghana after completing his studies but changed his mind after marrying a fellow student of Croatian origin and getting his first job as a doctor for tourists visiting the Slovenian seaside.
“I fell in love with this country. Slovenia is my home. Even my first impression of the country was good, it was so clean and green,” he said.