A man who shot an NYPD officer in Brooklyn on Thursday afternoon is dead from an apparent suicide, officials say.

Police said the man used a "long rifle" to shoot several times through a bedroom door inside his home on Ridgewood Ave. and Essex St. around 4:30 p.m.

He struck the male officer twice in his bullet-proof vest, police said.

The officer was transported to Jamaica Hospital. He is alert and in stable condition, officials said Thursday night.

Police said the man barricaded himself in the rear bedroom of the home after he shot the officer, but ESU emergency services made their way in around 7:15 p.m.

They discovered the man dead from what appeared to be self-inflicted gunshot wounds, Police Commissioner James O'Neill said in a press conference Thursday night.

Two guns were by his side, police said.

Dozens of officers were at the scene, including some state troopers. They may have treated it as a hostage situation, sources told NY1.

The officer shot had responded to a 911 call for an emotionally disturbed person, according to officials.

Police said the caller had reported that her 29-year-old son was not violent or armed, and was in her home with her.

O'Neill said multiple officers and EMS personnel responded to the scene, and that the officer shot had gone into the back of the home after the mother said her son may flee through the back door.

O'Neill said the officer, who has been on the force for about two years, did not return fire after the man shot him.

One neighbor described the shooter as a quiet man who kept to himself. "He is not a kind of person like that," the neighbor said. "I don't know how he would do this."

EMS personnel treated the officer on-scene before they transported him to the hospital.

Mayor Bill de Blasio and other officials visited the officer in the hospital.

The city police department had urged people to avoid the area from Ridgewood Ave. to Fulton St.

The police department originally said the officer shot is a woman.