By Allyn Fisher-Ilan
JERUSALEM, Oct 23 (Reuters) - The Israeli mayor of Jerusalem has won re-election in a hotly contested race against a challenger linked to a far-right opponent of Prime Minister Benjamin Netanyahu.
Former high-tech tycoon Nir Barkat won about 51 percent of votes in polling held on Tuesday, a count of all ballots showed. His main rival, Moshe Lion, polled about 45 percent. Other votes went to a third candidate.
In a predawn victory speech to cheering supporters on Wednesday, Barkat, 54, called the election "one of the most complicated and difficult races" he had seen, but was thankful to voters he said "gave us a mandate to lead the city with the same vision for the next five years."
Israeli media said Lion had also conceded the race.
The Jerusalem contest was seen as the most strategic of nearly 200 local government elections held across Israel, with a Barkat victory dealing a blow to his contender's main backer, far-right former Foreign Minister Avigdor Lieberman.
Lieberman, currently a lawmaker, had hoped a Lion victory would give him political momentum to mount a challenge to Netanyahu's leadership should he be acquitted in a corruption trial whose verdict was expected next month.
Barkat also outmaneuvered ultra-Orthodox opponents of Netanyahu's government who pundits said had teamed up with Lieberman in hopes of trying to leverage a defeat of the incumbent mayor to topple Netanyahu's ruling coalition.
Barkat was first elected as mayor in 2008 when he defeated an ultra-Orthodox leader, in a contest that turned largely on the city's sharp religious-secular divide. This time he won votes from secular and religious Israelis alike.
Though a political independent, Barkat championed Jewish settlement building in east Jerusalem in his first term, supporting Netanyahu's policies, yet was seen as more pragmatic than his opponent.
More than 750,000 people live in Jerusalem, about a third of them Palestinians, most of whom traditionally boycott the mayoral election in protest of Israeli rule in east Jerusalem, which Palestinians want to make the capital of a future state.
In a second high-profile local contest, Tel Aviv Mayor Ron Huldai was the predicted winner of a fourth term of office, in a contest against Nitzan Horowitz, a dovish lawmaker who would have been the first gay mayor in the Middle East.
Huldai, 69, won more than 54 percent of votes, according to a count of more than 80 percent of the ballots. Horowitz polled about 40 percent, media reports said. (Reporting by Allyn Fisher-Ilan; Editing by Eric Beech)