Cops were seeking a group of motorcyclists whose backfiring bikes sparked fears of an active shooter in Times Square, NYPD sources told The Post on Wednesday.

“There was a large roving band of off-road motorbikes that had altered mufflers,” a police official said.

“The mufflers are altered to give the sound of loud rapid gunfire.”

The backfires sounded after the six bikers turned east onto 42nd Street from Eighth Avenue shortly before 10 p.m. Tuesday, sources said.

Several cops on patrol heard backfires from multiple bikes and radioed the NYPD that while the noise resembled gunfire, they saw no weapons, sources said.

But the sound sent panicked tourists stampeding through the Crossroads of the World in an incident that Gov. Andrew Cuomo said showed how “petrified” people are following the recent mass shootings in El Paso, Texas, and Dayton, Ohio.

A dozen people — ranging in age from a 12-year-old girl to a 79-year-old woman — were hurt, with five taken to local hospitals for treatment of non-life-threatening injuries, the NYPD said.

The bikers could be charged with reckless endangerment for putting the crowd at risk, sources said.

State law also makes it illegal to modify a vehicle’s muffler to “amplify or increase the noise emitted by the motor or exhaust system.”

NYPD Counterterrorism Chief James Waters said detectives were reviewing surveillance video from the area but had yet to identify the bikers or determine whether the backfires were intentional.

“This could have been a malfunctioning motorbike,” he said.

“I think it would be unconscionable to have a device that would sound like gunshots.”

Waters also said the people who ran away during the false alarm “did what we asked them to do and what we implore them to do.”

“Run, hide, fight,” he said.

Waters also said some of the restaurants and theaters where people sought shelter “have received our training,” which involves “talking about counter-terrorism response and awareness and active shooters.”

A worker at the Hard Rock Cafe in Times Square said there was “absolute chaos” there when at least 100 frightened people “flooded in both doors” and ran through the ground-floor store and downstairs restaurant.

“They were under our counter, in our stockroom, hiding in our personal space,” the employee said.

“People were crying, screaming that there was a shooter.”

But the worker said that “being a New Yorker, I knew something wasn’t right because we didn’t see any of the police cars and vehicles you would expect to see if there [was a shooter].”

The panic ended, the worker said, when “some random guy, just off the street … poked his head in and said, ‘You know that was just a motorcycle, right?’”

By coincidence, the NYPD and FDNY held an active-shooter training exercise earlier Tuesday at Citi Field, where more than 100 cadets from the Police Academy pretended to be victims of several attackers armed with machine guns.

About 100 cops took part, including members of the Strategic Response Group, Emergency Services Unit and Critical Response Command, as well as cops assigned to NYPD’s Citi Field detail.

They were joined by about 50 firefighters and EMTs.

ESU cops tracked down and “killed” the mock shooters, a source who took part said, and the exercise wrapped up in time for the Mets to beat the Marlins, 5-0, Tuesday night.

The exercise, one of several conducted annually, was scheduled several weeks ago, the source said.