WAYNE, N.J. — Police broke up an illegal party inside a vacant commercial building in Wayne, detaining dozens of revelers including a suspect in a previous robbery, authorities said Thursday.

Cops learned on June 18 that the bash was being promoted on social media and was set to go down late that night, with as many as 500 attendees on hand, officials said in a press release.

Surveilling the building before the scheduled start time, police saw several people enter the private property through doors that had been previously forced open, authorities said. Wanting to shut down the event before the number of attendees got out of hand, police moved in.

All told, officers detained 47 people. Among them was Alejandro Perea Torres, a 20-year-old East Orange man wanted as a suspect in a previous robbery, officials said. He was arrested and turned over to East Orange police. The remaining detainees were positively identified by cops before being released pending possible future charges, police said.

Officials found the interior of the building trashed, including with crudely spray-painted directional signs for partygoers. The property manager has since boarded up the building to prevent future break-ins.

In a statement, the Wayne Police Department thanked other agencies for alerting them to the party, and warned that “this type of destructive, illegal behavior will not be tolerated.”