An attempted home invasion in Brooklyn turned deadly when the targeted homeowner shot the would-be robber twice.

Cops say the homeowner of a house on the 2500 block of East 64th Street in Mill Basin saw someone in his front yard at about 2 a.m. Wednesday.

The homeowner went to retrieve his gun and by the time he returned, the suspect was already broke into his home. The man shot the suspect twice in the torso.

The home invader was transported to Brookdale Hospital in critical condition.

Cops say the homeowner, a retired teacher, was defending himself and is not suspected of any criminality. They also say he has a valid license to carry and possess the handgun he used to protect himself.

Neighbors gave the homeowner credit for his actions.

"If somebody were to break into my house and try to harm my family, there's very little that's gonna come between me and my family," said local resident Mike Reinhardt. "I hope the perpertator is hurting [and] he learns his lesson so he can share his story with other people about breaking into other people's houses."

It is unclear why the house on East 64th Street was targeted, but residents told PIX 11 News there have been a number of break-ins in the area recently. They also said just one block away, a family was held at gunpoint during another home invasion and the suspect made off with $50,000 in cash and jewelry.