Two men were shot early Sunday morning in Brooklyn, cops said.

The pair — ages 29 and 51 — were fired on while standing outside on Pulaski Street near Stuyvesant Avenue in Bedford-Stuyvesant at 2:40 a.m. when a man in their group pulled a gun, according to the NYPD.

The 29-year-old was shot in the arm, and the 51-year-old hit in the groin, according to cops. Both were taken to Kings County Hospital where they are expected to survive.

It was unclear what sparked the shooting.