Mohamed al-Megaryef resigned Tuesday as leader of Libya's General National Congress (GNC) in compliance with a new law barring Muammar Gaddafi-era officials from government.
The new law passed on May 5 under pressure from gunmen who surrounded the Justice Ministry to press for the changes.
Megaryef was Libya's ambassador to India in the 1980s during the Gaddafi regime, just before defecting to become leader of the opposition.
"Everyone must obey the law out of respect for legality and democracy. I tender my resignation ... in conformity with the law," Megaryef said during a plenary session of the Congress.
"I leave with my head held high and my conscious clear."
More from GlobalPost: Gunmen surround another Libya ministry
Megaryef was to be replaced by an elected president of the GNC shortly after his resignation.
He was elected in a vote last August after spending 31 years in exile, 20 of which were spent in the United States.
Megaryef, along with other defectors, was hunted by the Gaddafi regime.
He also survived an assassination attempt earlier this year.
The new law banning Gaddafi officials comes into effect June 5.