Dr Peter Bossman, 55, a member of the Social Democratic Party, narrowly won out over the incumbent with 51.4 per cent of the vote. He celebrated his victory with his wife Karmen and two daughters and promised his 18,000 constituents that he would improve their already high living standards and take action against the town's drug problems. He also promised to introduce electric cars. "My victory shows a high level of democracy in Slovenia," Dr Bossman said, before waxing lyrical about his adopted homeland.
"I fell in love with this country," he told Reuters. "Slovenia is my home. Even my first impression of the country was good, it was so clean and green."
That warmth was returned by many Slovenians, whose imaginations were captured by Dr Bossman's story. On local news sites people described the election as "an important thing in the country" and "a very symbolic event". "We proved that tolerance does live here after all," a Facebook user said in his message to the new mayor.
But the medical doctor's route to Slovenia has not always been so blessed. Dr Bossman is the son of a personal friend and physician of the first leader of independent Ghana, Kwame Nkrumah. He spent his childhood living in northern Africa, Switzerland and Great Britain, where his father helped found Ghanaian embassies.
"I always knew I'd be a doctor, and I wanted to study in Britain, but things turned into different direction," he said in an interview with local media.
More than three decades ago, he was forced to leave Ghana after being persecuted by the military regime that overthrew Mr Nkrumah. The only place he could go to study was the former Yugoslavia. He hoped it would be Belgrade, but instead he was sent to the Slovenian capital of Ljubljana. He met his wife at the university and after graduation they moved to the coastal town of Piran.
Mr Bossman said that he had experienced problems because of the colour of his skin in the past, but that all that had changed over the last decade.
"Now I have no problems at all," he said. "I think people no longer see the colour of my skin when they look at me."
Mr Bossman's story coincides with a wider change in Slovenian attitudes to foreigners. Thousands of Serbs, Croats and Bosniaks became illegal residents in 1992 when the government deleted 25,671 people from official records because they did not apply for citizenship. Many fought long legal battles to prove their right to remain in Slovenia, gravely tarnishing the country's image as an idyllic Alpine nation. But at last this year they have been able to regain their residency status.
But Mr Bossman insists that his political agenda is limited to the town of Piran. "I'm happy to be the mayor, I live here," he said. "I have no further political ambitions. I promised my patients I'll remain their doctor after the elections. My doors will be always open for them. Here on the coast, people do not look at the colour of my skin, they know what kind of man I am."