Updated

An NYPD cop was shot in Brooklyn by a deranged man with a rifle — who opened fire on him moments after he entered his apartment — and then barricaded himself inside before taking his own life, police said.

Officer Hart Nguyen, of the 75th Precinct, was hit twice in the bulletproof vest and once in the arm while responding to a call of an emotionally disturbed person at a residence in 149 Ridgewood Ave. in Cypress Hills, the sources said.

He was rushed to Jamaica Hospital and was expected to survive.

“The vest definitely saved him,” Mayor de Blasio said at a press conference on Thursday night.

It was initially unclear if anyone else was inside the apartment while the suspect was holed up, but sources said it was the man’s mother who called the police on him.

“The mother called 911 because her son’s an EDP,” a source explained. “When [the officer] gets into the apartment, he comes out of the bedroom shooting.”

Police officials later revealed that the worried woman had told cops that her son was not violent — and unarmed — but acting erratically.

Click here for more from The New York Post.

Click for more from Fox 5.