A fugitive opened fire at police who tried to arrest him, leading to a lengthy standoff in downtown Salem City before the wanted man surrendered Wednesday afternoon, authorities said.

Members of a law enforcement task force were trying to arrest Eric Smith on a warrant for charges including aggravated assault on a police officer and for failing to appear in court when the ordeal began, according to Salem Police Chief John Pelura and court records. After an initial exchange of gunfire, a negotiator connected with Smith and he surrendered around 3 p.m.

Pelura said at least one task force officer returned fire. There were no injuries to Smith, 26, or law enforcement officers, according to New Jersey State Police.

As Smith left the building at 172 Broadway with hands up, family members yelled for him to follow orders from police. A crowd cheered as the standoff ended and members of the State Police tactical took the suspected shooter into custody.

Police could be heard using a megaphone to communicate with the man.

Smith, a Salem resident, was wanted because he had previously crashed his car into a police cruiser and fled a traffic stop in the city Jan. 7, according to the charging documents filed in Salem County Superior Court.

Police wrote that an officer stopped Smith’s vehicle at the Sunoco on East Broadway and called for backup after smelling marijuana in the car. Smith revved the engine and reversed his car “causing extreme risk of injury to the officers around the vehicle” and struck the cruiser behind him and a gas pump before fleeing, the complaint said. A high-speed chase ensued but was later terminated, the complaint said.

He was charged with four counts of aggravated assault on a police officer by attempting to cause injury and one count each of eluding and obstructing the administration of law.

Multiple police vehicles crowded around the building and armed police could be seen on the rooftops of buildings near the shooting scene. The bottom floor of 172 Broadway is a tax office with a separate entrance for what appear to be apartments on the second and third floors.

Salem County offices were placed on lockdown and authorities told people to stay away from the area.

“The Salem County Offices located in Salem City are currently on lock down,” the county posted on its Facebook page. “Please do not come in this surrounding area as currently there is an active shooter incident taking place.”

A satellite office for Salem Community College is on the block and the county courthouse is behind that row of buildings.

The college’s Salem Center building on Broadway was placed on lockdown at about noon, according to spokesman Bill Clark.

Sixteen workers at the Salem Center were evacuated by police escort around 12:30 p.m., Clark said. They are employed by the Salem County Chamber of Commerce and the state Department of Labor, he said. Salem City’s school were also on lockdown.

An employee at Pat’s Pizzeria, located near the shooting scene, confirmed the business was on lockdown after receiving a call from the sheriff’s office.

Market Street is blocked off, according to a bystander. Roads leading into the city were also blocked.

WATCH LIVE: Chopper 3 is live over the 100 block of East Broadway in Salem where New Jersey State Police say there is a possible shooter from a roof of a building. UPDATE: Police confirm a gunman has fired shots from the roof of a building. https://cbsloc.al/2FJthfA Posted by CBS Philly on Wednesday, January 23, 2019

Jeff Goldman may be reached at jeff_goldman@njadvancemedia.com. Follow him on Twitter @JeffSGoldman. Find NJ.com on Facebook.

Matt Gray may be reached at mgray@njadvancemedia.com. Follow him on Twitter @MattGraySJT. Find NJ.com on Facebook.

Have a tip? Tell us. nj.com/tips

Get the latest updates right in your inbox. Subscribe to NJ.com’s newsletters.