The activist preacher Al Sharpton on Saturday criticized detractors who blame police-brutality foes for a lone Dallas gunman who killed five police officers and injured seven others.

Speaking during his weekly Saturday morning rally in Harlem, Sharpton said he mourns the cops’ deaths on Thursday as well as those of two black men shot dead by officers days earlier — Philando Castile in Minnesota and Alton Sterling in Louisiana.

“I stand, and many others stand, and say that what this man did in Dallas was wrong and reprehensible,” Sharpton said, “but I want to see one good cop stand up and say, ‘It’s time for cops to have to pay if they commit a crime!’ ”

Sharpton said that the gunman, Micah Xavier Johnson, didn’t represent those seeking to stop undue police violence against blacks and Latinos and pushing for the prosecutions of cops who use excessive force.

“Don’t distort our movement,” Sharpton said. “Don’t break the law and act like we’re being, in some way, provocative, to ask you to enforce the law.”

Sterling, 37, was shot dead by an officer in a videotaped struggle with two officers in Baton Rouge. Castile, 32, was mortally wounded by a cop during a car stop in Falcon Heights, Minnesota, south of St. Paul. His girlfriend live-streamed the aftermath on Facebook. Both killings are being probed by investigators.

In the Dallas case, Johnson later told negotiators that he was angered by police killings of black men and had targeted whites that night. Police sent in a robot with a bomb to kill him after he refused to surrender.

Sharpton was joined at the rally Saturday by Gwen Carr, whose son, Eric Garner of Staten Island, was killed in 2014 by what the New York City medical examiner ruled was an NYPD chokehold during a botched arrest for selling loose cigarettes. Carr said she empathized with the Castile and Sterling families — as well as those of the slain cops.

“I can honestly say, I know what you’re feeling. I know what you’re going through, and I want to say, just try to be strong,” she said.

Carr said she can understand the frustration over injustice that motivated the gunman in Dallas, but she said: “Shooting those innocent police officers, why kill the innocent? They’re not the ones that shot your loved ones.”

“We don’t go down gunning down innocents,” she said. “We are about peace.”