An NYPD officer guarding Madison Square Garden for the Grammy Awards in Manhattan Sunday was injured when an unhinged man tried to grab her gun — and then hit her in the face with a laptop, police said.

Officer Magna Kamara, 26, was on paid detail at West 32nd Street and 7th Avenue when she was approached by man who began talking to her, police sources told the New York Post.

After a brief conversation, the 26-year-old man suddenly tried pulling her gun from its holster, but the officer was able to push him away, police said. After the failed attempt, the man tried to run away but Kamara pursued him. In an attempt to slow the officer down, he hurled a laptop back at her, hitting her in the forehead.

Kamara chased the man down and placed him under arrest, police said.

Kamara, who has approximately two years on the force and typically works in the 108th Precinct in Queens, was taken to Bellevue Hospital and treated for a laceration on her head, the sources said.

The officer’s gun was kept in place by her auto-locking SafariLand 6360 ALS gun holster, which the NYPD issued to officers in 2016 after the department’s push for safer, more secure holsters, sources said.