KABUL - Afghanistan's election commission declared Hamid Karzai elected as president on Monday after it called off a runoff following the withdrawal of his only rival.

The run-off, called after the first round in August was marred by widespread fraud, was to have been held on November 7.

The Independent Election Commission declares the esteemed Hamid Karzai as the president ... because he was the winner of the first round and the only candidate in the second round, the commission's chief Azizullah Ludin told a news conference.

Ludin told a packed media conference the decision was made to spare the Afghan people the expense and risk of another election and because a one-candidate race would raise questions about the legitimacy of the presidency.

Former foreign minister Abdullah Abdullah withdrew from the race over the weekend, citing doubts about the credibility of the election process.

Karzai has lost his legitimacy, he is a very weak president and he cannot govern without reaching out to Dr Abdullah, said Kabul-based political analyst Haroun Mir. So the ball is in Dr Abdullah's court right now.

Karzai's camp on Sunday had ruled out a coalition with Abdullah, but he has been under intense pressure from various quarters to bring Abdullah into the government.

Earlier U.N chief Ban Ki-moon made a visit to Kabul that had not been announced in advance, as diplomatic efforts gathered pace to resolve the prolonged political crisis.

We continue to stand by the people of Afghanistan in their quest for prosperity and peace, Ban said.

The withdrawal of Abdullah from the run-off had cast doubts over the legitimacy of the next government, already under a cloud following the August 20 election marred by allegations of fraud in favor of Karzai.

A weakened Afghan government under Karzai would be a blow for U.S. President Barack Obama as he considers whether to send up to 40,000 more troops to fight a resurgent Taliban in Afghanistan.

A spokesman for Karzai's campaign said the president will issue a statement about the election commission announcement later in the day.

Abdullah had left the door open for future discussions but said no deals had been struck in return for his withdrawal, seen by diplomats as one way to spare the country more uncertainty that discredits the government and can only aid the insurgency.

Ban ki-Moon met both Karzai and Abdullah, officials said.

A U.N. statement said the meetings were to assure them and the Afghan people of the continuing support of the United Nations doubts over the credibility of his government.

Ban made the visit after five foreign U.N. staff were killed in a suicide attack last week on a Kabul guest-house used by the United Nations.

The attack was claimed by the Taliban, who have vowed to disrupt the run-off and said the guest-house was targeted because of the United Nations' role in helping organize the Afghan election.

The run-off was ordered after a UN-led investigation panel found widespread fraud in favor of Karzai in the August 20 election.

(Writing by Paul Tait and Sanjeev Miglani; Editing by Jerry Norton)