Sadiq Khan, Labour Party candidate for London mayor. (Leon Neal/AFP)

Londoners voted Labour's Sadiq Khan as their new mayor this week. He will be the first Muslim mayor in Europe's largest city and the first elected Muslim mayor of any major European city.

Khan's status as an observant Muslim hasn't gone unnoticed. In fact, it has proved to be a sore subject in the remarkably bitter battle for London's top political office, where identity politics has trumped the slim policy differences between the candidates. Khan's supporters accuse his rival, Zac Goldsmith, the son of a billionaire financier, of using "dog whistle" tactics to tar Khan with allegations of links to extremists. Goldsmith penned an article in the Mail on Sunday that suggested that Khan had "repeatedly legitimized those with extremist views."

The article was illustrated with a picture from the July 7, 2005, bombings in London, which left 52 people dead.

But is it really so shocking that Europe's largest city would elect a Muslim mayor? Given that there are an estimated 1 million Muslims in London, around an eighth of the total population, perhaps not. The position of London mayor was created in 2000, meaning that Khan is not just the city's first Muslim mayor: He is also be the British capital's third mayor, period. And although Khan comes from a Muslim background — born to Pakistani parents in south London — his reserved manner and stance against extremism make him a less divisive figure than his somewhat notorious predecessors, the outspoken leftist Ken Livingstone and the publicity-savvy conservative Boris Johnson.

However, the situation Khan faced during his campaign may well be a broader sign of the difficulties Muslims in Western Europe confront when trying to get elected to office. The number of Muslim citizens has risen in many Western European nations over the past few decades. Perhaps it would be reasonable to assume that would mean more Muslim voters and more Muslim candidates for political office. The reality, however, is far more complicated — and not just because of religion.

Candidates of a Muslim background often run into concerns about Islamist extremism among the broader voting public. For Khan, the situation was been made worse by timing: The official start of campaigning in the London mayoral race began March 21, the day before Islamic State-linked bombers attacked Brussels and killed 32 people. Many experts argue that growing Muslim populations in Western Europe — or perhaps more accurately, the perception of growing Muslim populations — have helped contribute to the recent successes of a number of far-right, anti-immigrant parties across the continent.

According to research from Abdulkader Sinno, an associate professor of political science at Indiana University, there are only 70 to 100 lawmakers in Western Europe with some link to Islam, out of a total of about 8,000. Sinno notes, too, that some of those he counts are not observant Muslims and that it is simply a "matter of heritage." The situation varies greatly from country to country. In Britain, there are 13 Muslim lawmakers in the lower house of Parliament. This number is the highest it has ever been, but it falls short of being fully representative of the broader population: Muslims make up 2 percent of Parliament vs. 4 percent of Britain's population. In France, home to the largest Muslim population in Western Europe (amounting to about 8.5 percent of the total French population), there is just one lawmaker of Muslim background in the 577-member National Assembly.

Any distrust of Muslim candidates among a broader electorate isn't necessarily made up for by a new emerging class of Muslim voters, either. Jytte Klausen, a Danish-born scholar who teaches at Brandeis University in Massachusetts, says it is "a trope" that Muslims can influence electoral outcomes in Europe. "Overall, Muslims are about 3 to 10 percent of the population contingent on which country we are talking about," Klausen writes in an email. "About one-third is too young to vote. Many Muslims (again contingent on the country in question) do not have citizenship and therefore cannot vote."

Now Khan has been elected to the high-profile position of the mayor of London, it may well make him the best-known Muslim politician in Western Europe. Jonathan Laurence, an associate professor of political science at Boston College who studies Islam in Europe, says that other potential candidates for that title would include Ahmed Aboutaleb, the Moroccan-born mayor of Rotterdam, who was appointed in 2008 (mayors are not elected in the Netherlands); Cem Ozdemir, a German politician of Turkish origin, who became the co-chairman of the Green Party in 2009 after a lengthy career in the German and European parliaments; and Najat Vallaud-Belkacem, also born in Morocco, who was appointed France's minister of education, higher education and research in 2014.

Outside of religion, these politicians share something else: the left end of the political spectrum. When the mostly working-class migrants from Muslim-majority countries first arrived in Western Europe in the latter half of the 20th century, they found a natural ally in Europe's labor-focused parties. After the Sept. 11, 2001, attacks in the United States, there was a surge in the number of young Muslims in Western Europe running for office. In recent years, however, the number has fallen, Klausen tells WorldViews — not because of these Muslims' religious background, per se, but their political leanings. The socialist and democratic parties they favored were simply no longer winning elections.

Labour, the left-leaning party that Khan represents, is a prime example. After years of political dominance, it was trounced in a recent general election and is under the controversial leadership of Jeremy Corbyn, a stalwart of the party's leftist camp. Labour has recently become caught up in a party-wide scandal about anti-Semitism that has embroiled not only Livingstone, the former London mayor, but also lawmaker Naz Shah. There are even widespread rumors of a plot to remove Corbyn after this summer's vote on whether Britain should leave the European Union. It is, if appearances are to be believed, a party in crisis mode.

But Khan's campaign for mayor was never in crisis mode. Polls repeatedly showed that despite the stories that attempt to link him to extremism and the chaos in his party, he had a very comfortable lead over Goldsmith going into the voting on Thursday. The final results seem to suggest a remarkable win, comfortable enough that it cannot really be explained by either religious or party identity.

More on WorldViews

Why Brits are so angry about David Cameron’s family wealth

Zionism and Hitler? A guide to the wild scandal rocking Britain’s left

The petty, mean and deliciously rude ways British politicians insult one another