(corrects spelling of analyst's name)
By Hamid Shalizi and Katharine Houreld
KABUL, March 9 (Reuters) - Afghanistan's powerful vice president, Marshal Mohammad Qasim Fahim, died of natural causes on Sunday, only weeks before the country is due to elect a new leader. He was 57.
Once one of Afghanistan's most feared warlords, Fahim had been a top commander in the Northern Alliance, a group of anti-Taliban militia leaders, after the 1992-96 civil war.
"It is with deep sadness that we learn of the passing away of Marshal Mohammad Qasim Fahim, the First Vice-president of the Islamic Republic of Afghanistan. May his soul rest in peace," President Hamid Karzai's office said, declaring three days of national mourning.
The United Nations mission in Afghanistan called Fahim "a good and trusted partner of the U.N.". Back in 2009, U.N. officials and diplomats had criticised Fahim's appointment because he was accused of serious human rights abuses.
It was unclear what, if any, role Fahim had planned for next month's presidential election.
Pictures on local media showed government dignitaries streaming into pay their respects to Fahim, whose body was wrapped in an embroidered gold robe.
He fought alongside U.S. troops to defeat the Taliban and was a staunch backer of Karzai, whom he promoted as Afghanistan's interim leader and later served as both defence minister and vice president.
Fahim, vice president since 2009, spoke little to the media, said Kate Clark of the Kabul-based thinktank Afghanistan Analysts Network, but wielded great influence in closed door meetings.
"Karzai, Fahim and the Americans have been the three key powers in Afghanistan since 2001," she said. "He was one of the key people to win over because he carries a lot of influence within ... one of the big political- military parties."
Human Rights Watch said in a 2005 report that Fahim was "one of the most notorious warlords in the country, with the blood of many Afghans on his hands from the civil war".
The presidential election is due to take place on April 5. If it proceeds normally, it will mark the first time in Afghanistan's history that power has been handed from one democratically elected government to another.
Seen as a quiet powerbroker, Fahim had been courted by several candidates but had not publicly committed his support, said Amrullah Saleh, a former Afghan intelligence chief who was close to Fahim.
"I didn't hear any indication that Marshal Fahim was opposing any side in the election process," Saleh told ToloNews, a local television station.
Behind the scenes, Fahim's loyalties had swung between different candidates, said Davood Moradian, the head of the Kabul-based Afghan Institute for Strategic Studies.
Fahim had links with the both president's brother, who stepped down this week in favour of Zalmay Rassoul, another candidate close to the president, and Abdullah Abdullah, a former aide to Masoud, he said.
Hamid Karzai is barred by the constitution from seeking a third term. He has not publicly offered his backing to any of the candidates. However, many observers say the new alliance of Karzai's brother and former foreign minister indicates that ticket has presidential approval.
The election is taking place against a backdrop of uncertainty and deteriorating security as U.S.-led forces in the country since the Taliban were ousted in 2001 are due to withdraw by the end of the year. (Editing by Jeremy Laurence)