An NYPD cop was clocked in the head and injured by a bicycle thrown from a fifth floor window in Brooklyn early Sunday, authorities said.

The cops were called to the building on St. Mark’s Avenue near Albany Avenue in Crown Heights at about 2:05 a.m. for a report of gunshots fired, when they arrived debris started to rain down from one or more balconies, officials said.

One officer was struck in the back of the head by a bike, but miraculously avoided a direct hit and serious injury, according to cops.

The officer was rushed to Kings County Hospital in stable condition.

Two other cops suffered minor injuries while arresting the suspected gunman, authorities said.

It was not immediately clear whether the individual who dropped the bike had been apprehended. Police in SWAT gear were attempting to gain entry to several fifth-story apartments by 3 a.m. in hopes of finding the culprit or culprits.