These undated photos provided by the Baltimore Police Department show, from left, Daniel Hersl, Evodio Hendrix, Jemell Rayam, Marcus Taylor, Maurice Ward, Momodu Gando and Wayne Jenkins. (Baltimore Police Department via AP/AP)

The officers’ job during some of the bloodiest years in Baltimore was to get guns off the streets.

Instead, they plundered money, jewelry, drugs and weapons and gouged the cash-strapped city for overtime and hours they never worked, according to their own admissions and testimony in ongoing criminal cases.

Over the past four years, some members of the Gun Trace Task Force stole more than $300,000, at least three kilos of cocaine, 43 pounds of marijuana, 800 grams of heroin and hundreds of thousands of dollars in watches from suspected drug dealers and civilians, according to officers’ plea agreements and statements in federal court.

They admit to putting illegal trackers on the cars of suspected dealers so they could rob their homes and sell off any drugs and guns they found. The squad sergeant, Wayne Jenkins, carried brass knuckles, a machete and a grappling hook — all shown to jurors — in case they found a “monster” dealer to swindle, two officers testified in Baltimore over the past week. Those officers testified that Jenkins also told them to carry BB guns to plant at crime scenes in case they needed to justify why they had hurt someone.

As they went rogue, the same officers took home hundreds of thousands of dollars in unearned overtime pay from a city struggling to pay its teachers.

“It was like a way of life,” former detective Jemell Rayam testified Monday. “We got away with a lot of things.”

Two former detectives who pleaded not guilty, Daniel Hersl and Marcus Taylor, are on trial in a case expected to last about two weeks and include testimony from several of their victims. Three former colleagues have taken the stand against them, providing new revelations that expand on the criminal behavior exposed in earlier plea agreements, including one from Jenkins to robbery, obstruction of justice, racketeering and violating people’s constitutional rights.

Once heralded as a beacon of Baltimore’s commitment to rooting out street violence, the tarnished task force stands now for corruption and dysfunction in a department under federal surveillance and battling record-high murder rates.

“The police department knew what was going on” with the gun squad, said Ivan Bates, a defense attorney running to succeed Baltimore State’s Attorney Marilyn Mosby. “Everybody knew who they were.”

He represented several victims who had been arrested by the unit and said he knew city prosecutors had reservations about the officers’ credibility. Several of the officers have been the targets of lawsuits and internal investigations in the past.

But, Bates said, especially in recent years law enforcement officials were so desperate for arrests that they let the squad run wild. “The city is in chaos, the police department doesn’t work with the state’s attorney, and they need to find any police who can make some arrests,” Bates said.

Amid the turmoil and surge in violent crime that includes the unsolved killing of a city homicide detective, the city’s police commissioner, Kevin Davis, was abruptly replaced Jan. 18.

The illegal activity in the gun unit was uncovered by a Drug Enforcement Administration investigation that caught one officer talking to a drug dealer on a wiretap.

Only one member of the nine-member task force has not been charged with a crime: Detective John Clewell.

“Clewell really didn’t take the money,” Rayam testified. “He wasn’t part of the team.”

The team was productive: Nearly 3,000 cases in Baltimore involve the eight indicted officers, according to the public defender’s office. And the fallout from the indictments has been substantial.

Four people arrested by the unit have been let out of federal prison; other federal cases are being appealed by the public defender’s office.

The state’s attorney’s office estimated in November that 277 cases have been affected by the indictments and 125 have been dropped. Another 71 are under review.

As the head of the once-lauded unit, Jenkins was a “golden boy” and “untouchable” in the department, defense attorney William Purpura, who represents Hersl, said in court Monday. In addition to Jenkins, Rayam and four others from the gun squad, including former sergeant Thomas Allers, have pleaded guilty to fraud and racketeering crimes.

As squad members, Evodio Hendrix, Rayam and former detective Maurice Ward testified they routinely ignored constitutional protections and entered homes without search warrants, and stopped people without probable cause — then lied about it. It was common practice, Rayam said, to put GPS trackers on cars illegally to make it easier to follow people the squad intended to rob.

“We would create false reports to cover up the robberies we were involved in,” Hendrix testified.

They would also lie to cover up their mistakes.

Jenkins has admitted writing a false report involving heroin planted in a car in 2010 after a high-speed chase that left an elderly bystander dead. Both men in the car spent years in prison. One was released last August, halfway through a 15-year sentence, because of the revelations.

After that car crash, Jenkins told officers to carry BB guns in case they needed to plant one on a suspect, Hendrix and Ward testified.

At least 20 and sometimes 50 times a night, Ward testified, the squad would create a pretext for a chase by pulling up on groups of men, quickly opening their car doors to startle them and see who fled, giving the officers an excuse to follow and possibly find something illegal.

Most of the time, Rayam and Ward testified, the officers would steal a fraction of a suspect’s money and deflect scrutiny by turning in most of the contraband.

“If the person complained, they would be admitting to the drugs and the guns, so the majority of the time people wouldn’t complain,” Rayam testified.

The squad shorthand included “taxing” a drug dealer — meaning it would take some money from a dealer without charging him, as Rayam explained on a phone call played in court.

But both Rayam and Ward admitted to more brazen robberies. In 2014, warned against targeting an apparently legitimate pigeon business, Rayam roped in two non-officers to steal $20,000 from the owners.

The criminality ramped up, Ward testified, after the spring 2015 protests against law enforcement and rioting that followed the death of Freddie Gray from an injury in police custody.

Jenkins admitted in his plea that during the rioting, he stopped someone who had looted a pharmacy, seized the stolen drugs and then passed them off to a drug dealer for a split of the proceeds.

Around that time, Ward, Jenkins and Taylor intercepted a major drug deal and stole 30 pounds of marijuana and at least $15,000, Ward testified. They divvied the money in the woods and after that, according to prosecutors, Jenkins went to a strip club and robbed a stripper.

In March of 2016, Hendrix told jurors, officers stopped a suspected drug dealer and entered his house under false pretenses. At the house, Hendrix said, they broke into a basement safe where Jenkins removed stacks of cash, returned $100,000 to the safe, then directed another officer — Taylor — to videotape Jenkins opening the safe as if for the first time.

Federal agents arrived and seized the $100,000. Jenkins admitted in his plea that he kept $200,000, some of which he split with other members of the unit.

Taylor used his cut to build a deck on his home, according to Hendrix.

The squad would regularly do such “sneak and peeks,” Hendrix testified — going into a house without a search warrant — “to see if there was anything . . . worth taking” before other law enforcement arrived.

In June of 2016, Jenkins took over the Gun Trace Task Force and brought Hendrix, Taylor and Ward to the squad with him.

With Jenkins in charge, Rayam testified, “the robberies increased a lot more. Pretty much any individual that we came across, if they had large sums of money, it was taken.”

In September of 2016, Jenkins and Taylor were thwarted from robbing a major cocaine trafficker in Prince George’s County only because they encountered a DEA agent trailing their target, Rayam testified.

During other stops when he pilfered drugs, Jenkins sold what he had stolen through his intermediary, eventually netting at least $200,000.

Atop the money they pulled in on the streets, members of the squad admitted to generously padding their time cards.

“All of us were just nonchalant,” Rayam testified. “We pretty much came into work whenever we wanted to, left whenever we wanted to.”

If one person brought in a gun, they would fill in overtime slips for everyone else on the squad, Rayam said. And they would all claim to have worked as late as whoever left headquarters last.

Hersl once took an entire month off to remodel his home and still got paid, Rayam testified.

Purpura, who represents Hersl, has argued that the detective was involved in only minor theft. The defense attorney elicited testimony from several witnesses that overtime fraud was widely endorsed in the department as a way to motivate officers, especially when morale was low after Gray’s death.

“There are currently active internal investigations into anyone who may have enabled any members of the Gun Trace Task Force and their criminal actions,” Baltimore Police Department spokesman T.J. Smith told the Baltimore Sun.

The officers who have pleaded guilty in the case are Allers, 49; Hendrix, 32; Jenkins, 37; Rayam, 37; Ward, 36; and Momodu Gondo, 34.

Most face up to 20 years in prison. Under his plea agreement, Jenkins will serve at least 20 but no more than 30 years.

“The only thing that is surprising to me with these trials are the actual guilty pleas and that officers are going to prison,” said Ray Kelly, who leads the West Baltimore advocacy group No Boundaries Coalition. “For years we have talked about and tried to identify the levels of corruption within the BPD, and now our concerns are, sadly, being validated.”