Three undercover police officers were shot at — two received minor injuries — in an ambush Friday night in the city’s Cedarbrook section, police said.

Just after 8 p.m., the 14th District officers were in an unmarked vehicle heading east in the 1400 block of Sharpnack Street when an unidentified male on a bicycle began riding along the driver’s side, police said.

The officer driving rolled down his window and asked the male “if he was OK” and the male then pulled out a gun and began firing into the vehicle, police said.

The unmarked vehicle, which was struck several times by gunfire, rolled up on a sidewalk and into a fence just past Fayette Street. The officers got out of the vehicle and two returned fire, police said.

A second male on Sharpnack Street then began shooting toward the officers. Both shooters then fled in an unknown direction.

Police said a bullet pierced the driver’s seat of the police vehicle but was stopped by the officer’s ballistic vest. He was taken to Einstein Medical Center and listed in stable condition.

A female officer in the backseat sustained cuts from flying fragments of either bullets or glass to her left leg. She was also reported in stable condition at Einstein.

The third officer who was in the front passenger seat was uninjured.