Essam el-Erian and Mohamed Mursi, both members of the group’s Guidance Office, which acts as its executive committee, were detained in May during protests in solidarity with Egyptian judges demanding greater judicial independence.
Their detention had been renewed every 15 days until the court heard their appeal on Monday and ordered their release, their lawyer, Abdel Moneim Abdel Maqsoud, said.
The Muslim Brotherhood is one of the largest Islamist political movements in the Arab world.
The officially banned but tolerated group fielded candidates as independents in the November-December parliamentary elections and won 20% of seats in the People’s Assembly, becoming Egypt’s largest opposition group.
The group helped to organise street protests in May in solidarity with the two judges who faced disciplinary proceedings for speaking about allegations of vote-rigging last year.
Egyptian police allegedly organised plainclothes security men to attack the demonstrators.
In June too, hundreds of members of the group were detained after joining demonstrations in support of the judges.