Egypt's Justice Minister Ahmed Mekki resigned on Sunday, ahead of a cabinet reshuffle in which he was expected to be replaced, the cabinet said.
"Justice Minister Ahmed Mekki resigned this morning and will remain in his post until a new minister is appointed as part of the reshuffle," cabinet spokesman Alaa al-Hadidi said.
President Mohamed Morsi had said on Saturday he would order the reshuffle "soon," after months of pressure by opposition groups which demand an overhaul of the government before dropping a boycott of parliamentary elections.
Egyptian media had reported that Mekki would be one of the ministers replaced in the shake up, which a presidential aide told AFP would affect up to eight ministries, including "important ones."
Once a leading dissident judge under ousted president Hosni Mubarak, Mekki has faced criticism from both the opposition and Morsi's supporters.
"Ever since I became justice minister, your opponents have insisted I resign, in conformity with my past stances," Mekki wrote to Morsi in his letter of resignation, published by the official MENA news agency.
"Under the slogan of 'cleansing the judiciary,' and with the issuing of a new judicial law, your supporters have also demanded my resignation to achieve their goals, and to reach a consensus," he wrote.
Mekki has switched off his phone and could not be reached.
Morsi's administration had repeatedly clashed with the judiciary, which has accused the Islamist president of encroaching on its independence, leaving Mekki, once a senior judge, in the uncomfortable position of defending Morsi.
He had threatened to resign after Morsi adopted extensive powers in November that infuriated the judiciary, but remained in his post.
Prime Minister Hisham Qandil's government, appointed after Morsi's election in June, has tried to cope with a haemorrhaging economy despite billions of dollars in aid from energy-rich Qatar and some other countries.
The opposition has set Qandil's departure as a condition for dropping a boycott of parliamentary elections, possibly in the autumn.