JERUSALEM (AP) -- After a nail-biting race that went on long into the night, the secular mayor of Jerusalem won a second term Wednesday in a hard-fought campaign that saw him fend off a challenger backed by two of Israel's biggest kingmakers in an election that was the centerpiece of nationwide municipal voting.
"Jerusalem won," Mayor Nir Barkat declared in a victory speech at about 3: 30 a.m. He told supporters it had been a "tough and complex" battle and called for unity, saying "Jerusalem has room for everybody."
Barkat won 51 percent of the vote while 45 percent went to Moshe Lion, who conceded defeat an hour earlier.
But the tough race belied the low turnout at polling stations across the country. Only 36 percent of Jerusalemites voted, compared to 31 percent in Tel Aviv and 45 percent in Haifa, according to media reports.
Initially, the low turnout was seen as playing to Lion's advantage as more motivated voters cast ballots in religious neighborhoods, considered Lion strongholds. The tide changed in Barkat's favor in the early hours Wednesday as more votes were counted.
Jerusalem's Arab community could have in theory swing the city election, but -- as in previous years -- it boycott this year's vote to protest Israel's control of the city. The international community does not recognize Israel's control of east Jerusalem.
Barkat, a successful former high-tech entrepreneur, first became mayor in 2008 in a victory seen as a blow to years of dominance by the strict ultra-Orthodox sector over Jerusalem's affairs. His first term, marked by high-profile tourism and cultural projects meant to boost the economy and halt an exodus of secular residents from the city, was generally seen as a success.
However, Lion, a former director of the prime minister's office, was backed by two key politicians elbowing to reclaim their former political glory. His backers -- Foreign Minister Avigdor Lieberman and Ariyeh Deri, leader of the ultra-Orthodox Shas Party -- both had much at stake.
Lieberman's party lost seats in the last national election, and he is awaiting a verdict next month in an ongoing corruption trial. Shas was once a kingmaker in Israeli politics, but it no longer sits in the ruling coalition and faces a leadership crisis following the recent death of its spiritual leader, Rabbi Ovadia Yosef.
Critics say Lion is a political novice who relocated to Jerusalem recently to run for the job. In a recent TV interview, he failed to answer basic questions about Jerusalem's landmarks.
Himself an observant Jew, Lion was counting heavily on ultra-Orthodox voters. But in a last-minute blow, two leading ultra-Orthodox rabbis declined to endorse him late on Monday, telling their adherents to vote according to their conscience.
Jerusalem is one of the world's most difficult cities to govern: it lies at heart of the Israeli-Palestinian conflict and is the epicenter of secular-religious battles for control in Israel.
It is also Israel's largest city, and its 800,000 residents include secular, modern Orthodox, and ultra-Orthodox Jews as well as Palestinians.
The Arab population lives almost entirely in east Jerusalem, the sector captured by Israel in 1967 and claimed by the Palestinians as their capital. Jerusalem's old city in the eastern sector is home to a compound sacred to Jews as the Temple Mount and to Muslims as the Noble Sanctuary. Jews revere it as the site of their two biblical Temples. Muslims regard it as Islam's third-holiest site.
As he cast his vote on Tuesday, Prime Minister Benjamin Netanyahu reiterated his stance on the city's future.
"So long as I am prime minister, Jerusalem will remain our united capital. That's how it will be," he said.
The Israeli government is responsible for peace talks with the Palestinians. While the Jerusalem mayor has no official say in the city's political future, he can affect local Arab-Jewish issues such as building permits, construction, education and public services.
Barkat says that in his five years as mayor, he has halted the exodus of tens of thousands of secular Jerusalemites, revived the city's cultural life and improved the quality of life for its Arabs.
Still, Jerusalem remains one of the poorest cities in Israel, and Lion says Barkat placed too much emphasis on cultural activities at the expense of affordable housing and sanitation. Dovish Israelis have also accused Barkat of neglecting east Jerusalem's Arabs and having a cozy relationship with hard-line settler groups.
In Tel Aviv, popular mayor Ron Huldai kept his seat while lawmaker Nitzan Horowitz failed to make history and become the country's first openly gay mayor.
And in the Arab city of Nazareth, firebrand lawmaker Hanin Zoabi lost in her race against a powerful incumbent in a bid to become the country's first female Arab mayor.
Copyright 2013 The Associated Press. All rights reserved. This material may not be published, broadcast, rewritten or redistributed.