The 71-year-old banker, seen as a proxy for the ruling party, won by just 7,269 votes over his closest challenger out of 2.1 million valid votes cast in Saturday's four-way race to become head of state.

Tan got 744,397 votes, 35 percent of the total, well below the 60 percent garnered by the People's Action Party (PAP) in general elections held in May, its worst showing after 52 years in power.

Analysts said Tan could have lost in a straight one-on-one fight, and he immediately reached out to voters who rejected him.

"The president is a president for all Singaporeans, not only for those who have voted for me but even for those who have not voted for me. I pledge to work for each and everyone of you," he said after his victory was announced.

Prime Minister Lee Hsien Loong appealed for national unity after an intense campaign dominated by calls from government critics for a politically independent president who can act as a check on the PAP.

"Now that the election is over, we should all come together again as Singaporeans, to tackle the challenges that Singapore faces, and take our nation forward," Lee said.

Bridget Welsh, a political science professor at the Singapore Management University, said Singaporeans "are tired of elitism" and Tony Tan was seen as a representative of the political establishment.

"Singaporeans want more checks on PAP," she said, adding that voters now feel "empowered" and no longer afraid to speak for change.

The Elections Department ordered a recount of all votes cast after the first tally showed the two frontrunners were less than two percent apart.

Presidential candidates run as individuals in keeping with the non-partisan nature of the job, but Tony Tan was widely associated with the PAP -- he quit the party only in June to run for president.

His closest rival was former MP Tan Cheng Bock, a plain-speaking doctor who positioned himself as a champion of ordinary Singaporeans and called for a clear separation between the presidency and the government, despite being a former PAP member himself.

The president has veto powers over key government appointments and safeguards Singapore's foreign reserves, which now total around ê250 billion.

Singapore is a former British colony with a Westminster-style parliamentary system. It set up the presidency in 1965 when it became a republic after being ejected from the Malaysian federation.

Until Saturday's vote, there was limited political interest in the presidency, which was widely seen as a ceremonial job involving state visits, charity fundraisers and playing the starring role in the National Day Parade every August 9.

But emotions were still running high three-and-a-half months after the May general election, especially in social media and political websites that now set the tone for the national political debate.

Tony Tan served for 27 years in parliament and ran five cabinet ministries before moving on to the Government of Singapore Investment Corporation (GIC), which invests Singapore's foreign reserves.

The closely fought race exposed a vastly torn electorate, said Murray Hiebert, a senior fellow at the Washington-based Center for Strategic and International Studies' Southeast Asia programme.

"I think it shows Singaporeans pretty evenly divided between those who wanted to support the candidate most closely identified with the PAP and give the government a vote of confidence, and those who wanted a more independent president," he told AFP.

Tan Cheng Bock, 71, the runner-up, said before the election that the president "must not be a proxy of any political party."

"His interest must be national, not with a political agenda in mind."

Prime Minister Lee overhauled his cabinet after the May parliamentary polls, which he called a "watershed" in Singapore politics.

Lee's predecessors -- his own father Lee Kuan Yew and Goh Chok Tong -- retired as cabinet advisers as part of the reshuffle.