A gun-slinging woman on a bicycle shot a 28-year-old man in the face as she was aiming for her ex-boyfriend in Brooklyn, police said.

Victim Nelson Rivera, 28, was standing next to his buddy — the intended target — inside the lobby of a building on Montauk Avenue near New Lots Avenue in East New York just after 8 p.m. Thursday, sources said.

The two men had just had words with the woman on the sidewalk before she rode away in a huff when they turned to walk into the building.

As they were standing in the lobby, the woman fired a shot while seated on her bike and struck Rivera in the face. It’s believed she was aiming for the other man, who investigators believe may have been a former boyfriend, cops said.

The injured man and his pal ran up the steps to the roof of the three story building, leaving a trail of blood on the staircase.

When police arrived on scene, Rivera was staggering down the steps with a gunshot to the left side of his face, cops said.

He was treated at Brookdale Hospital.

Police said they are looking to question a person of interest in the shooting, described as a 25-year-old woman. Police declined to identify her.