State police say the incident began around 6:45 p.m. Tuesday at the intersection of Fourth and Sassafras streets, where two troopers stopped a silver Hyundai Santa Fe with two occupants inside.
Authorities say the passenger, identified as James Zigler III, provided false information to troopers before getting out of the vehicle and running away.
Troopers chased Zigler on foot, and police say he fired four shots at them. The troopers took cover behind parked vehicles and were not struck, authorities said.
"I heard three gunshots. I didn't think nothing of it. I knew it sounded kind of close," said Shayna Harris of B&B Barber Shop, near where the shots were fired.
Police say the gunfire occurred near 6th and Sassafras streets, close to the barber shop. Business owner Barry Cephas said he was later told what had happened.
"They said one individual opened fire on a police officer, state trooper, actually. Got out and ran and fled on foot," Cephas said.
Chopper 6 video showed investigators working in the area for several hours as they searched for surveillance footage.
Zigler was later found at a residence about a mile from the shooting scene and taken into custody, according to state police.
Residents described the incident as unsettling.
"There's been a lot of activity in Millville. I think they're doing the best they can with what they have," said Mary Lou Hess of Millville.
Cephas said he was worried about the risk to bystanders. "It does concern me because there's a lot of innocent people, and a lot of times innocent people are the ones who will get hurt."
In addition to the attempted murder charge, Zigler faces weapons charges, including possession of hollow-point ammunition.
He is being held in the Cumberland County Jail pending a detention hearing.
The driver of the Santa Fe was also arrested and charged with obstruction.
Police have not said why the traffic stop was conducted.