Morocco's King Mohammed VI has pardoned almost 9,000 prisoners to mark the birth of his daughter.
It is customary to mark special occassions with royal pardons
More than 24,000 prisoners are to have their sentences reduced, the justice ministry said in a statement.
The BBC's Richard Hamilton in Morocco says it is the largest number of inmates to be given a royal pardon.
Human rights groups have often criticised the cramped conditions in which an estimated prison population of 55,000 are incarcerated.
Amongst those still held in detention are hundreds of suspected Islamist militants who were arrested in the wake of suicide bombings in Casablanca in 2003.
The justice ministry said the pardon was motivated by humanitarian considerations, and a wish for prisoners to be re-integrated into Moroccan society.
"The releases have already begun and could take as long as a week to be completed," a ministry spokesman is quoted by Reuters news agency as saying.
Our correspondent says it is customary in the North African kingdom to mark national and religious holidays and special occasions with prisoner releases.
There has been great excitement over the birth of the king's new daughter and second child, Princess Lalla Khadija, which happened earlier this week.
The monarchy is venerated by Moroccans and the king is believed to be a descendant of the Prophet Muhammed, our reporter says.