A Ghana-born doctor nicknamed "the Obama of Piran" became the first black mayor in eastern Europe yesterday after he was elected in Piran, south-western Slovenia.

Peter Bossman, 54, said he was "happy and proud" to have been elected to the post after winning a second round runoff in the town with just over half the votes.

Bossman settled in Slovenia, then still part of Yugoslavia, in the 1970s after arriving in the country to study medicine. He decided to stay after marrying a fellow student from Croatia.

Speaking about his campaign, in which he said he would introduce electric cars to the town, Bossman said: "I based my campaign on a dialogue, and I think the dialogue has won."

But Bossman was criticised during the campaign for not speaking fluent Slovene, the country's official language, prompting him to say in an interview with Delo, one of Slovenia's leading newspapers, that a friend and professor of Slovenian had "offered to give me additional lessons".

However the new mayor, who runs his own private medical practice and is a member of Slovenia's governing centre-left Social Democrat party, said he had not suffered racial discrimination.

"In the first months after coming to Slovenia I felt that some people did not want to be with us [African immigrants]. But for the last 10 or 15 years … I have no problems at all and I think people no longer see the colour of my skin when they look at me," he said.

Slovenia has a population of around 2 million, the majority of whom are native Slovene, and immigration is more common from ex-Yugoslavian countries such as Bosnia and Herzegovina and Serbia. There are very few black people living there. The town of Piran, which lies on the Gulf of Piran on the Adriatic Sea, has a population of around 17,000.

Vlado Miheljak, a political analyst, said the vote in Piran was a test of whether Slovenia was "mature enough to elect a non-white political representative."