CHICAGO (CBS) — A purported gang member has been charged with shooting an ATF agent last week in an ambush in the Back of the Yards neighborhood.

Ernesto Godinez, who turns 28 on Wednesday, made an initial court appearance Tuesday morning on a count of forcible assault of a law enforcement officer. About 100 ATF agents filled the courtroom as Godinez quietly told the judge he understood the charges against him.

Ernesto Godinez is charged with shooting an ATF agent in the Back of the Yards neighborhood on May 4, 2018. (Credit: Chicago Police)

U.S. Magistrate Judge Maria Valdez ordered him held in custody until his detention hearing on May 17. Federal prosecutors argued he was a flight risk and a danger to the community.

Godinez turned himself in with his lawyer on Monday, sources told CBS 2. He has an extensive criminal record, including a conviction for attempted murder in 2011.

Police said Godinez ambushed an undercover ATF agent who was trying to place a tracker on his car around 3:15 a.m. Friday, during a joint mission by Chicago Police and the Bureau of Alcohol, Tobacco, Firearms and Explosives. Authorities said Godinez came out shooting when he spotted the agent placing the tracker on his car.

The ATF agent and Chicago police officer both returned fire at the scene, and following protocol, both were taken to the emergency room.

According to the criminal complaint against Godinez, at least three surveillance cameras in the area recorded the moments leading up to and after the shooting. Godinez allegedly is seen leaving his house at 43rd and Wood moments before the shooting, then walking down an alley, and toward 44th and Hermitage just before the shooting; then running back through the alley to his house just after the shots were fired.

The wounded agent was rushed to the hospital in critical condition, with a bullet wound to his face. He is expected to survive. The CPD officer was not hurt.

Police and federal agents scoured the Back of the Yards neighborhood for days after the shooting, executing at least eight search warrants. Agents in full armor used battering rams to knock down doors over the weekend.

A $61,000 reward had been offered for the gunman’s capture.

If convicted, Godinez faces up to 20 years in prison.

“I know that in the past several days it has not been easy for both the ATF who had one of their agents seriously injured and also for the residents of the Back of the Yards as we work to bring this criminal to justice,” said Chicago Police Supt. Eddie Johnson.