The officers were shot around 10:30 p.m. when they approached two possible suspects in the grocery store robbery outside a nearby Chinese restaurant on Tiebout Avenue near East 184th Street. One of the suspects then walked into the restaurant; as the officers approached the other man on the street, the suspect in the restaurant ran out and fired at the officers, Mr. Bratton said. The officers returned fire, and the suspects fled on foot before carjacking a white Camaro that had two women inside, he said.

The police found the car abandoned near East 188th Street and Park Avenue and recovered a black revolver nearby, Mr. Bratton said. They are investigating whether the man who fired at the officers was also involved in the earlier robbery at the grocery store, which is on 180th Street, Mr. Bratton said.

The officers were part of a five-member plainclothes anticrime team in the 46th Precinct and were nearing the end of their shift, Mr. Bratton said. When a call came in reporting the grocery store robbery, all five officers jumped into a car to investigate.

Mayor Bill de Blasio, who has come under harsh criticism from police unions after the killings of the two officers last month, praised the officers who were wounded on Monday night for their quick action.