An officer in New York City Mayor Bill de Blasio’s security detail was shot with a pellet gun Sunday night outside Gracie Mansion, according to NYPD sources.

The officer and her partner were getting out of an unmarked police car near the mayor’s Upper East Side residence shortly after 7 p.m. when she “felt pain in the lower back,” a department spokesman told the New York Daily News.

De Blasio was not home at the time.

The pellet broke the plainclothes offier’s skin, but did not lodge in her body, and the officer was taken to Lenox Hill Hospital for treatment.

She has since been released.

Police took in two teenagers, an 18-year-old boy and a 17-year-old girl, for questioning.