“They were simply put, both cops and robbers,” said Leo Wise, the lead federal prosecutor, in his opening argument.

The trial comes amid intense scrutiny on police departments nationally, and mounting pressure on officers to work to heal rifts with minority communities after findings by the Justice Department that some departments, including those in San Francisco, Chicago and Baltimore, have a pattern of unconstitutional and biased policing.

In Baltimore, the members of the anti-crime unit were so reckless that they carried out elaborate criminal schemes even as Justice Department investigators were scouring departmental records and interviewing the officers’ colleagues as part of their civil rights investigation. The gun unit’s criminal schemes appear to have started at least five years ago.

But the officers believed that their victims would not speak up. “More than likely, a drug dealer is not going to complain about their money being taken,” said Momodu Gondo, a former member of the gun unit who testified Monday. He wore an orange jail jumpsuit, having pleaded guilty to an array of crimes.

Mr. Gondo estimated that he had stolen as much as $100,000 from people during his career and said he had once given a gun he took during a home invasion to a friend who was a drug dealer.

The police accounts continue a drumbeat of negative news that has battered Baltimore’s police, which was highlighted by Freddie Gray, who died in 2015 from injuries sustained while in police custody. His death was followed by days of rioting and unsuccessful attempts to prosecute the officers involved in his arrest.