Whatever you do, Robert Kyagulanyi’s mother told him when he was a young boy growing up in a rough Kampala neighbourhood, stay away from politics. Mr Kyagulanyi, a Ugandan pop idol better known as Bobi Wine, has roundly ignored that advice. This week he contested presidential elections, voting for which took place on Thursday.

At 38, Mr Wine is the main challenger to President Yoweri Museveni, 76, who has used every organ of state and trick in the book to prolong his 35 years in power.

During the campaign, Mr Wine has been shot at, beaten and thrown in jail more times than he can recall. Scores of his supporters were killed in November, and his campaign events have been stormed by police. Even his trademark red beret has been outlawed. In the run-up to polling day, much of the internet was disabled and his campaign team arrested.

With a third of the votes counted on Friday, the official tally showed Mr Museveni winning comfortably, with 63 per cent of the vote. But Mr Wine, on 28 per cent, called those results a “joke” and declared himself president-elect.

“I have been targeted with bullets and tear-gas canisters, and wounded by the police and soldiers on a daily basis,” Mr Wine told the Financial Times last week. He has taken up boxing the better to sustain regular beatings. Two years ago, police pummelled him unconscious with an iron bar and, he says, used pliers on his testicles.

In his black Cadillac Escalade with a “Ghetto” vanity plate, Mr Wine can appear all hip-hop bling. In person, he is softly spoken, articulate and deadly earnest about toppling one of Africa’s longest-reigning autocrats.

Whatever the final result, his impact goes well beyond Uganda, a country of 44m people where the median age is just 16. In much of Africa, he represents a new force in politics — a disenfranchised urban youth, ambitious and connected, but frustrated by a lack of job opportunities and by the governance of mostly elderly leaders. “Bobi strikes me as an individual with remarkable courage and tenacity of conviction,” says Wole Soyinka, a Nigerian Nobel laureate. “The age of gerontocracy should be formally declared over.”

Mr Wine was born in 1982, four years before Mr Museveni seized power after fighting a bush war against dictator Milton Obote. His grandfather died in that conflict and his father, a staunch Museveni supporter, fled to Tanzania. Mr Wine’s mother, a former midwife, was left alone to bring up nine children in Kamwokya, a Kampala slum, where she worked as a market trader. It was quite a comedown. Mr Wine’s great-grandfather had been a chief and his grandfather “a gentleman”.

“My mother always reminded me that we are in the ghetto because of politics,” he says. She encouraged hard work, instilling in him a belief in what he calls his “uptown character”. She scrimped to send him to a fee-paying school and he later graduated from Makerere University, Uganda’s oldest, with a degree in music, dance and drama.

From an early age, he played music, later changing his name to Bobi after Bob Marley, the Jamaican reggae singer. Wine, he says, was because he was improving with age. Supplementing his income with jobs from bricklaying to collecting edible grasshoppers, by the age of 20 he had scored his first hit with a dance track.

In 2000, he met Barbie Itungo, a young woman from a better-off family then finishing boarding school. “I was an errant young man, but when I met my wife, hey, it was so much transformation,” he says. The couple went on to have four children, two boys and two girls, now aged five to 15.

His songs became more political, excoriating everything from bad sanitation to bad government. Earlier efforts had included anti-homosexual jibes for which he later apologised, calling them the product of youthful ignorance. Mr Museveni, a virulent homophobe, has seized on that to brand him an agent of foreign homosexuals. In 2017, Mr Wine ran for parliament — protest songs could achieve only so much. Styling himself the “ghetto president”, he won by a landslide. In 2019, he declared his intention to run for president.

Khatondi Soita, a 26-year-old journalist, says she isn’t exactly a supporter. “But my God, he’s such a force.”

In candid moments, Mr Wine admits he is unqualified to be president. His political platform is long on idealism and short on policies. “I never believed that I’m the person cut out for this,” he says. In Kampala, especially in poorer areas, he is greeted with raised fists and chants of “people power”. Supporters hoist him on their shoulders and occasionally prostrate at his feet. He worries they expect too much.

In the countryside, where Mr Museveni’s political machinery is most entrenched, Mr Wine’s popularity is harder to gauge. He points to large rallies — when he has managed to evade the police — and to polls that he says shows strong support.

Mr Wine’s intention was to win so overwhelmingly that Mr Museveni had no option but to go. Political analysts judged that unlikely, particularly given the president’s control over the electoral process. If Mr Museveni declares victory, mass protests could follow, though Mr Wine says he eschews violence.

Win or lose, he will stay in Uganda, he says. “If I die, I want to die here.” Asked last week how he was doing, he replied: “I’m alive.” In an election year in Uganda, that is no small achievement.