Chowchilla Police officers responded to the gunfire on First Street and Humboldt Avenue.
The victim was driven to the police department, then rushed to a hospital.
Officers were able to track down the suspect vehicle after being alerted by the Madera County Sheriff's Office.
Deputies stopped the vehicle in Fairmead and found guns and drugs.
27-year-old Edgar Ventura, 18-year-old Christian Estrada, 20-year-old Alexis Palacios and a juvenile were booked on several charges.
Officials say this appears to be a gang-related incident.