KARACHI, Pakistan — The yellow-walled, colonial-era central prison in Karachi houses some of the city’s hardened criminals, but one of its inmates, Waseem Akhtar, still has a day job: He’s the mayor of Pakistan’s biggest and most tumultuous city.

Mr. Akhtar won election here on Aug. 24, a victory that was largely symbolic.

Mr. Akhtar belongs to the Muttahida Qaumi Movement, or M.Q.M., a political group that led this chaotic, violent city for decades through a combination of political guile, violence and intimidation. Now, the party is struggling in the face of a crackdown by the military, which has put Mr. Akhtar’s electoral victory in the cross hairs. The mayor continues to languish behind bars, and it remains unclear when he might be able to perform his official duties.

Mr. Akhtar took the oath in a park last Tuesday, transported there from his prison cell for the occasion.

“There are a lot of issues in the city, but with full determination and motivation, we will resolve all of them,” he said at his inauguration. “I will seek my freedom from the court. Otherwise, I will run the city by setting up an office in my prison cell.”