Peter Bossman, a candidate of the centre-left Social Democrats (SD), narrowly won a municipal election in the Slovenian coastal town of Piran.
He said people no longer saw the colour of his skin and his election showed the “high level of democracy in Slovenia”.
Mr Bossman came to the country in the 1980s, when it was still part of the former Yugoslavia, to study medicine.
He won a narrow victory over the previous mayor, Tomaz Gantar, with 51.4% of the vote.
Mr Bossmann said he was “happy and proud”.
“I based my campaign on a dialogue, and I think the dialogue has won,” he said.
His campaign pledges include the introduction of electric cars in Piran. He also hopes to develop an airport and a golf course to boost tourism.
‘No problems at all’
The 54-year-old had aimed to return to Ghana after his studies, but changed his mind after marrying a fellow doctor of Croatian origin.
About 12% of the population of Slovenia, which declared independence in 1991 and became the only former Yugoslav state to join the European Union in 2004, were born abroad, but only a fraction come from Africa.
Mr Bossman told the Reuters news agency that he had faced no discrimination because of his skin colour or origins in recent years.
“There are always small groups of people not accepting people who are different and in the first months after coming to Slovenia I felt that some people did not want to be with us,” he said.
Source: BBC
“But for the last 10 or 15 years, I experienced nothing like that any more. I have no problems at all and I think people no longer see the colour of my skin when they look at me,” he added.