A school-safety agent was gunned down by a masked attacker on a Brooklyn street last night — and his dad said a jealous lover could be to blame.

“They shot me! They shot me in the shoulder!’’ cried off-duty NYPD employee Brian Green, 25, to his mother after being nailed by a bullet inside his parked black Infiniti just before 6 p.m. in East Flatbush, according to a witness.

Green’s dad, Basil, 58, told The Post his son “just said somebody came up to the car and shot him.”

Despite the wound, Green tried to flee the shooting scene.

“He was very scared,” his father said. “He ran down the driveway, he was running for his life. He had to be targeted. He’s lucky to be alive. He was shot right in the chest . . . right over the heart.’’

Brian Green was in stable condition last night.

Basil Green suggested that his gregarious, lady-loving son might finally have rubbed someone the wrong way.

“He’s a friendly guy,’’ Basil said. “His mother’s been warning him about his women. He’s always coming around with strange girls. It could have been some spurned boyfriend or jealousy going on with a woman.

“He goes with a woman and then leaves them and they get someone’’ to exact revenge, the dad said.

Police could not provide any motives as of last night.

Although Green, as a school-safety agent, wears a cop-like uniform, he does not carry a gun.

He has been with the NYPD since 2009 and is currently assigned to a school in Crown Heights, sources said.

His aunt, Hyacinth Bernard, said he had just gotten a job with the city Corrections Department.