At the start of the year, Conservative Party HQ was gloomy about the party’s prospects of retaining the London Mayor’s post at the 5 May election. It was obvious that Zac Goldsmith was “no Boris Johnson”, the man he aspired to succeed at City Hall. Goldsmith was running a lacklustre campaign and Sadiq Khan, the Labour candidate, was ahead in the opinion polls.

Some Tories spotted a silver lining, arguing that it might be “good to lose” in London as that would make it harder for Jeremy Corbyn’s Labour critics to oust him, boosting Tory prospects at the 2020 general election. But Downing Street was alarmed by such defeatist talk: running a city of eight million people is a big job and London is a huge political prize. Johnson’s triumph in a natural “Labour city” in 2008 gave a big push to David Cameron’s drive to lead his party out of the wilderness. Retaining the mayor’s post in 2012 was another coup.

So Number 10 was instrumental in injecting some energy and discipline into the Goldsmith campaign. It turned to Crosby Textor Fullbrook, the firm headed by Lynton Crosby – the hard-nosed Australian strategist who helped Cameron win an unexpected majority at last year’s general election.

Mark Fullbrook is Goldsmith’s campaign director. His presence was felt immediately when Goldsmith unveiled a four-point “action plan” on housing, transport, the environment and crime, echoing the Tories’ “long-term economic plan” last year. But the polls in the capital did not shift and, just as Cameron needed to undermine Ed Miliband by claiming he would be in the SNP’s pocket in a hung parliament, the Tories decided to play the man as well as the ball in London.

They have seized on Khan’s alleged links to several Muslim extremists and helped hostile newspapers to uncover them. He had “shared a platform” with some unsavoury characters – which, if it were an offence, most politicians would be guilty of at some point. Khan insists that he represented some of the extremists as a solicitor; defended others as chair of Liberty, the human rights group, and met others as MP for Tooting – including Suliman Gani, an imam at the local Islamic Centre.

The Tory attacks were raised to new decibels on Wednesday when Cameron said at Prime Minister’s Questions that Khan had appeared on a platform nine times with Gani who, he claimed, “supports IS” (Isis).

Cameron, who was branded a “racist” by furious Labour MPs, may have picked an unfortunate example. Gani, who has attended conferences that discussed an Islamic state, insists he does not support Isis. He supported the Tory candidate in Tooting last year and met Goldsmith at an event to which he was invited by the Tories. Labour says Gani campaigned against Khan because the MP backed same-sex marriage, and that Khan was involved in him being removed from the mosque because of his views.

The latest polls show Khan still ahead of Goldsmith and in public Labour claims the relentless Tory attacks are backfiring, saying they might have worked 20 years ago but do not in today’s London. Privately, some Labour figures are worried that drawing attention to Khan being a Muslim might swing some wavering voters. They know that Crosby proved the pollsters wrong a year ago and would not advise a nice guy like Goldsmith to play nasty unless he was convinced it would work – most probably in the outer London boroughs, where Khan has worked hard to win over floating voters wowed by Johnson.

The Tories accuse Labour of screaming “Islamophobia” to prevent legitimate scrutiny of Khan’s judgment, claiming he has not explained all his links. But some Tories are appalled by a campaign that, as Khan argued at a London Evening Standard hustings on Thursday, has imported Donald Trump’s tactics into British politics. Playing the Muslim card is totally at odds with the One Nation legacy Cameron wants to leave, which includes a clampdown on discrimination.

Mayor of London 2016 - the candidates at a glance Show all 7 1 /7 Mayor of London 2016 - the candidates at a glance Mayor of London 2016 - the candidates at a glance Sadiq Khan - Labour The MP for Tooting, Sadiq Khan says the mayoral election will be a 'referendum on the Tory housing crisis'. He has also pledged to freeze fares until 2020. Son of a bus driver, and doesn't let anyone forget it. His Conservative opponent has made claims about people who he has previously associated with - but attacks so far have failed to stick Mayor of London 2016 - the candidates at a glance Zac Goldsmith - Conservative The MP for Richmond, Zac Goldsmith is a longstanding campaigner against the expansion of Heathrow airport. Despite his environment credentials - he once edited The Ecologist magazine - the Tory candidate has said he would 'rip out' Boris Johnson's cycle lanes if they don't work. A very wealthy man, his campaign has been dogged by accusations of racism against Sadiq Khan Mayor of London 2016 - the candidates at a glance Sian Berry - Green Party A councillor in the London Borough of Camden, Sian Berry is campaigning on improving homes for renters, cleaning up London's air pollution, and flattening fare zones to help Londoners. She previously ran as the party's mayoral candidate in 2008. In 2012, the Green Party came in third place Mayor of London 2016 - the candidates at a glance Caroline Pidgeon - Liberal Democrat A Liberal Democrat London Assembly member for eight years, Caroline Pidgeon has a strong record on the Assembly's transport committee standing up for commuters and cyclists alike. She wants to set up a £2 billion housing investment fund and make all the capital's buses zero emission Mayor of London 2016 - the candidates at a glance Peter Whittle - UKIP UKIP hasn't fared so well in London in previous elections, but is hoping for a breakthrough this time. Peter Whittle has been UKIP's culture spokesperson for two years. He tends to focus on the impact of immigration on London's housing crisis Mayor of London 2016 - the candidates at a glance George Galloway - RESPECT George Galloway has made a habit of defying the odds and pulling off stunning victories when standing for Parliament. His campaign - based on the slogan 'a London for all' has so far failed to make headway in the polls - has his luck run out? Mayor of London 2016 - the candidates at a glance Sophie Walker - Women's Equality Party A journalist, Sophie Walker is campaigning for the little-known Women's Equality Party. She is pledging to make 'equality and diversity the fuel that drives our nation's capital' with measures to increase women's representation in enterprise, more affordable homes and flexible childcare

As Baroness Warsi, the former Conservative Party chair, put it: “If Sadiq Khan isn’t an acceptable enough Muslim to stand for London mayor, which Muslim is?” Khan has spelled out plans to tackle extremism and terrorism. There is a real danger that moderate Muslims will look at the nasty party’s attacks on him and conclude that entering public life is not worth the candle. That would be very bad news for all of us, since the best antidote to the extremists’ poisonous views is moderate Muslim voices. Like Khan.

There are plenty of other fruitful lines of attack against Khan—flip-flopping to oppose a third runway at Heathrow; nominating Jeremy Corbyn as Labour leader and then distancing himself as soon as Labour members chose him to run the mayoral race. Their laser-like, Crosby-driven focus on what they regard as their trump card has eclipsed the real issues facing Londoners.