As cops were being threatened and assaulted and the city reeled over the execution of two officers, Mayor Bill de Blasio prayed at St. Patrick’s Cathedral Sunday — then went into hiding.

Police Commissioner Bill Bratton visited the scene of the horrific attack in Brooklyn and Gov. Andrew Cuomo paid a wrenching condolence call at the home of one of the slain cops, but de Blasio ran from reporters and was nowhere to be found after the church service.

He showed up for 10:15 a.m. Mass with his wife, Chirlane McCray, and Bratton, with all three sitting in a front-row pew as Cardinal Timothy Dolan urged prayers for the slain cops’ families, the NYPD — and the embattled mayor.

Dolan asked Bratton to tell cops that “we love them very much, we mourn with them, we need them, we respect them, we’re proud of them and we thank them.”

Reporters were then told to leave the church early for a nearby news conference with the mayor, but de Blasio — who was snubbed by scores of cops at Woodhull Hospital on Saturday — scooted out after the service and ignored questions as he hopped into an SUV.

In other developments while de Blasio was AWOL:

The NYPD said it is investigating more than a dozen threatened copycat attacks after Officers Wenjian Liu and Rafael Ramos were shot execution-style. One man was busted for allegedly attacking an officer in the 28th Precinct station house in Harlem on Sunday.

President Obama personally called Bratton on Sunday to express his condolences over the killings and offer his support, the White House said — while indicating that only the president’s staffers reached out to de Blasio.

The department suspended patrols by its Volunteer Auxiliary Police, whose members wear uniforms and ride in marked vehicles but are not armed.

Surveillance video revealed that killer Ismaaiyl Brinsley spoke with two strangers shortly before his Saturday rampage, telling the men to “follow me on Instagram and watch what I’m going to do,” cops said.

EMT Tantania Alexander recalled trying to save the shot cops, with Ramos struggling to tell her his name before blacking out.

The New York Rangers held a moment of silence for the fallen officers at Madison Square Garden on Sunday night.

The Brooklyn Nets honored the cops at Barclays Center.

After an hourlong sit-down with Ramos’ family, Cuomo said, “An attack on a police officer is an attack on every law-abiding person in the city of New York, and that’s what this was.”

He also spoke by phone with Liu’s widow, who told him she was too distraught to see him in person, a Cuomo spokesman said.

Shabhan Ali, a neighbor of Liu, fumed outside his Bensonhurst home Sunday about de Blasio’s no-show.

“[Liu] was a hero and was protecting the city. De Blasio should pay his regards,” he said.

Outside Ramos’ Cypress Hills home, the president of the 75th Precinct Community Council, John Rodriguez, seethed, “Come out here and show this family some respect — that’s what [de Blasio] should do.”

It was unclear Sunday if Ramos or Liu had signed forms distributed by their union last week for cops to ask that neither de Blasio nor Council Speaker Melissa Mark-Viverito attend their funerals if they are killed in the line of duty.

A cousin of Ramos, Richard Gonzalez, said de Blasio “could come if he wants.”

“We’re not disrespectful. We’re not going to throw him out and say, ‘Don’t be here,’ ” he said. “We want to bury our cousin and our son and grieve in peace.”

Former NYPD Commissioner Ray Kelly blamed de Blasio for inflaming anti-police sentiment after the grand jury decision in the death of Eric Garner.

“I think when the mayor made statements about that he had to train his son to be — his son who is biracial — to be careful when he’s dealing with the police, I think that set off this latest firestorm,” Kelly said on ABC’s “This Week.”

Ex-Mayor Rudy Giuliani faulted President Obama and Attorney General Eric Holder as well as de Blasio.

“We’ve had four months of propaganda starting with the president that everybody should hate the police,” he told Fox News.

Additional reporting by Lorena Mongelli, Dana Sauchelli and Geoffe Earle

How New Yorkers can help

As the city mourns the loss of two NYPD cops killed in the line of duty over the weekend, New Yorkers can lend a helping hand by donating to a college fund for the two sons of one of the fallen officers.

The Silver Shield Foundation is seeking donations for Officer Rafael Ramos’ sons, Justin and Jaden.

The other cop killed Saturday, Officer Wenjian Liu, did not have children.

Justin Ramos attends Bowdoin College in Maine. Jaden, 13, attends Charles O. Dewey MS in Sunset Park, Brooklyn.

Contributions can be made to: Silver Shield Foundation, 870 United Nations Plaza, 1st Floor, New York, NY 10017.

The Silver Shield Foundation helps the children of fallen cops and firefighters from the tri-state area pay for their education.