By Syed Raza Hassan

KARACHI (Reuters) - The mayor-elect of Karachi, detained last month on allegations that he helped militants and criminals, vowed on Wednesday to run Pakistan's largest and richest city from his prison cell.

Waseem Akhtar's Muttahida Qaumi Movement (MQM), which swept local elections in December, was prevented from taking office then because of delays in finalizing local council elections in parts of the city. The final voting took place on Wednesday.

Early on Wednesday, Akhtar arrived in an armored police vehicle at the Karachi Metropolitan Corporation building to vote in elections that give MQM, which has dominated politics and commerce in Karachi for decades, an unassailable lead.

"Thank you Karachi, which has gone through this election in such difficult times," Akhtar said after he voted. "It will go down in history that such an election has never before taken place in Pakistan."

Security forces, political parties and criminals are all vying for greater control of Karachi, a port city that is home to 20 million people, the stock exchange and central bank, as well as militants and gangsters.

MQM has dominated the city for decades but a paramilitary crackdown since 2013 has undermined its power base.

Security forces have arrested scores of MQM members in the last year and accuse them of torture, murder and racketeering. MQM denies any link to crime and accuses paramilitary forces of a series of extra-judicial killings of its members.

Politicians can govern from police custody under Pakistani law but it is not clear how Akhtar could run the city from his prison cell. The courts are not expected to release him before he takes his oath, a ceremony likely to be held on Aug. 30.

He said he would ask the chief minister of Sindh province to allow him to open an office in jail and make "new rules" so that people could access him.

His lawyer, Mahfooz Yar Khan, told reporters outside the council building that the new mayor would run Karachi via video link for the whole five-year term of office if necessary.

Senior Karachi-based figures in the secular-leaning MQM this week pledged to reduce the sway of their London-based leader, Altaf Hussain, who on Monday urged supporters to attack the office of a TV channel in clashes that left one dead.

(Additional reporting by Mehreen Zahra-Malik; Writing by Tommy Wilkes; Editing by Louise Ireland)