London (AFP) – London was on course to become the first EU capital with a Muslim mayor as voters went to the polls Thursday following a bitter campaign that stayed ugly to the very end.

Labour’s Sadiq Khan, the son of a bus driver from Pakistan, voted early in his multi-ethnic constituency of Tooting in south London.

His main rival, environmentalist Zac Goldsmith, cast his ballot in the posh Richmond neighbourhood west of the city centre.

The vote is seen as the first major electoral test for opposition Labour leader Jeremy Corbyn, whose party has been riven by infighting over allegations of anti-Semitism.

The results of the regional elections that are also being held in Scotland, Wales and Northern Ireland will likely set the tone for the final seven weeks of campaigning ahead of Britain’s June 23 EU membership referendum.

In the Scottish Parliament, First Minister Nicola Sturgeon’s pro-independence party is looking to tighten its hold on power as it seeks to build support for a second vote on seceding from the UK following a failed referendum on the issue in 2014.

If Britain as a whole votes to leave the European Union but Scotland votes to stay in, Sturgeon says that would be a pretext for her Scottish National Party to demand another independence referendum.

– Khan v Goldsmith –

In London, polls show the city facing a straight choice between Labour candidate Khan and his Conservative rival Goldsmith.

The campaign has been dominated by negative campaigning, with Goldsmith seeking to establish links between Khan and Muslim extremists, which Khan has consistently dismissed as “desperate stuff”.

Cameron echoed the theme in parliament on Wednesday in terse exchanges with Corbyn.

Khan, 45, is the son of a Pakistani immigrant bus driver who became a human rights lawyer and government minister, while ecologist Goldsmith, 41, is a son of the late tycoon financier James Goldsmith, a scion of one of Britain’s wealthiest families.

Despite the surface-level rancour, both candidates accept that the sky-high cost of homes and the city’s creaking transport system are the dominant issues for voters.

Of the 12 candidates, second preference votes for the top two are added on to determine the winner. Final opinion polls put Khan 12 to 14 points ahead on second preferences.

London’s Evening Standard newspaper endorsed Goldsmith on Wednesday, as he spent the last day of campaigning on a 24-hour tour of the city.

“Of the two strong candidates, he has more compelling ideas on tackling pollution and congestion,” it said.

During a visit to a street market in south London on Wednesday, Khan told AFP his rival had run a “negative, divisive and increasingly desperate campaign”.

“I’ve had a positive campaign from day one, talking about how my experience, values and vision will lead to me being the mayor for all Londoners,” he said.

The new mayor replaces the eccentric Conservative Boris Johnson, whose eight-year term in office included the London 2012 Olympics and the launch of a cycle hire scheme dubbed “Boris Bikes”.

Out of London’s City Hall, the fiercely-ambitious Johnson — a leading figure in the EU referendum’s “Leave” campaign — is the bookmakers’ favourite to become Britain’s next prime minister.

– Acid test for Corbyn –

The elections are a much bigger test for Corbyn, the socialist stalwart who won the Labour leadership in September in a surprise landslide.

If Labour loses ground, moderates and centrists within the party — who held the ascendency under prime ministers Tony Blair and Gordon Brown — could seek to stage a leadership challenge, according to newspaper reports.

While London chooses a new mayor, there are also elections to the Scottish, Welsh and Northern Irish assemblies, and 124 local authorities scattered across England.

In Wales, polls put Labour on course to retain their dominance. The Conservatives and nationalists Plaid Cymru are vying for second place.

In Northern Ireland, where power is shared between parties, the Democratic Unionists (pro-British Protestant conservatives) were narrowly ahead of Sinn Fein (left-wing Irish republicans) in the final opinion polls.