A New Jersey man who accidentally flew a drone into the Empire State Building was arrested on Thursday after he asked security guards there for help retrieving it from a ledge on the famed skyscraper’s 36th floor, the police said.

Sean Riddle, 27, of Jersey City, was arrested shortly before 8 p.m. on Thursday on charges of reckless endangerment and avigation in and over New York City, a charge the police apply in cases related to the navigation of an aircraft.

The police said that Mr. Riddle was flying his drone in Midtown Manhattan on Thursday when it crashed into the building’s 40th floor.

The device fell from the sky after striking the building, landing on a ledge four floors down. Mr. Riddle then entered the building to ask security guards for help.