Morocco's courts are convicting people using evidence that defendants claim is obtained through torture or falsified, a report from Human Rights Watch says.
Failure to investigate allegations of illegal practices in effect encourages torture and other abuses, it warns.
The Moroccan authorities say they have taken steps to reform the judiciary.
The report was based on five trials between 2009 and 2013 involving pro-democracy protesters, terrorism suspects and Western Sahara activists.
Of the 77 people whose cases were examined in the report, 76 were convicted and 38 remain in prison.
One of the trials saw the conviction by a military court in February of 25 Sahrawi civilians - the indigenous population of Western Sahara - accused of attacking security forces as they dismantled a protest camp in 2010.
The court failed to take into account defendants' claims that they had been tortured or coerced into making false statements, the HRW report says.
It calls for the 21 defendants still in prison to be freed, and for any retrial to be conducted by a civilian court.
The report also criticises the use of contested evidence in the trial of 35 terrorism suspects arrested in 2008, and that of six members of the 20 February protest movement.
"It is not clear whether the failures of the Moroccan judicial system in these cases reflect a lack of judicial independence - pressure or interference by the executive branch or another party - or simply poor-quality justice," it says.
Moroccan law criminalises torture and prohibits courts from using evidence obtained under "violence or coercion".
King Mohammed VI announced a major push to reform the judiciary in 2009.
In 2011, a new constitution was introduced, widely seen as an effort to avoid an uprising of the kind that happened in Tunisia, Egypt and other Arab countries.
It included a number of articles that provided for strengthening judicial independence and defendants' rights.
A charter on judicial reform commissioned by the king is expected to be published in the coming weeks.