A 22-year-old man was shot six times while on his way to the Cook County Criminal Court building in Chicago Monday morning.

Around 9:30 a.m., the man was walking toward the courthouse in the 2600 block of South California when a white van drove by and someone inside the vehicle opened fire, police said.

Police initially said at the time of the shooting the man was entering the courthouse, but later clarified that he was on his way to the courthouse and was close to the building when shots were fired.

The man suffered six gunshot wounds to the groin and was transported to Mount Sinai Hospital in critical condition.

Police said an offender was taken into custody a outside the courthouse and a weapon was recovered. Charges were pending as of 11 a.m.

"The Cook County Sheriff's Office is vigilant about the safety and security of the public and of the jail compound," the sheriff's office said in a statement. "The recent events, while tragic, are not indicative of security breaches. We will continue to provide 24/7 security to the jail compound."