There has never been a better time to break the law in New York.

For the past month, the city's police officers have been looking the other way as people ride the subway without paying, cycle through red lights, break the speed limit and drink in public. Although the ­Patrolmen's Benevolent Association says there has been "no union-initiated or supported slowdown," officers have written 93% fewer summonses than they did in the same period a year ago.

On Hogmanay, one million people gathered in Times Square, watched over by thousands of police officers. Normally, hundreds of revellers start the new year with a date in court. This time, not a single ticket was issued for carrying an open bottle of booze, double parking, or urinating in the street. Broken Windows policing, an approach pioneered by New York Police Commissioner William Bratton and founded on the principle that small crimes matter, has been temporarily suspended.

The industrial action began in response to the execution of two police officers on December 20. Wenjian Liu and Rafael Ramos were shot dead in their patrol car by Ismaaiyl Brinsley, hours after the gunman posted a threat to put "wings on pigs" to avenge the deaths of Michael Brown and Eric Garner, two unarmed black men killed by white policemen.

Another policeman, Kenneth Healey, had recently been wounded with an axe in broad daylight. "Here you have an officer who was ­standing in the street and ­someone came and attacked him with a hatchet. Two others were executed," says Dennis Gonzalez, an NYPD veteran of 29 years who currently serves with the department's intelligence bureau. "If I'm an officer on patrol, am I going to bury my head in a summons book or am I going to be aware of my surroundings?"

Last week, two more police officers were shot, although not seriously wounded, when they tried to stop an armed robbery. "Those officers who got shot in the Bronx were off-duty," Gonzalez says. "That tells you right there that, no matter what, we're going to do the job we're paid to do."

Bratton hailed the most recent arrest figures - a 38% year-on-year decrease - as a sign that ­"officers are beginning to re-engage", but many are still sitting on their hands. The dispute at the root of the slowdown, between the police union and the mayor of New York, Bill de Blasio, is no closer to being resolved.

"The real crime, you know, cops are still gonna go after," says Ken McGrath, a retired deputy chief who spent 37 years on the force, many of them as a precinct commander in downtown Manhattan. "But when they see things in the grey area and they feel that the mayor doesn't have their back, they say, 'well, why should I get involved in that?'"

The execution of Liu and Ramos brought into the open a row that had festered for months. The president of the police union, Patrick Lynch, blamed "those that incited violence under the guise of protest" for the murders, implying that the ­peaceful demonstrations seeking justice for Brown and Garner had inspired the killer. He added: "That blood on the hands starts on the steps of City Hall in the office of the mayor."

At the funerals of Liu and Ramos, hundreds of police officers turned their backs on de Blasio as he ­delivered a eulogy. "I think it ­probably did go a little too far," says McGrath. "But there are consequences when people speak. There's a lot of crazy people out there and they get revved-up by this rhetoric."

Almost every day, de Blasio is attacked on the front pages of the city's two tabloids, the New York Post and the Daily News. But in the New York Times, an editorial took the NYPD to task: "With these acts of passive-aggressive contempt and self-pity, many New York police officers, led by their union, are squandering the department's credibility, defacing its reputation, shredding its hard-earned respect."

Others echoed the newspaper's view. "The same way we wouldn't want them profiling the African-American community, I don't want to do the same for the law enforcement community," says Kirsten John Foy, a senior staffer at ­Reverend Al Sharpton's National Action Network, and a former aide to de Blasio. "There are 35,000 cops and many of them have shown a great deal of respect for the mayor, but many of them have shown disrespect and disdain for both the city they serve and the mayor they work for."

De Blasio was unpopular with police before he took office at the start of last year, thanks to a campaign promise to end the department's controversial "stop-and-frisk" policy. From 2002 to 2014, New Yorkers were stopped and interrogated by police officers about five million times. Almost 90% of the people stopped were black or Latino, and - according to the department's own figures - 90% were innocent of any crime.

Five months before the end of mayor Michael Bloomberg's tenure, a federal judge ruled that the policy amounted to racial profiling. De Blasio swore to drop the city's appeal against the verdict.

More than anything, though, police hostility to the mayor can be traced back to his comments after a Staten Island grand jury declined to press charges against officer Daniel Pantaleo. The video of Pantaleo choking Garner, who died shortly afterwards, fuelled widespread protests against police impunity and spawned a new slogan: "I can't breathe."

De Blasio spoke about the need for young black men to exercise caution around police officers, with particular reference to his son, Dante, who is mixed race. To African-American parents he was stating a fact, but many police found the speech offensive.

"Chirlane and I have had to talk to Dante for years about the dangers that he may face," de Blasio said. "We've had to literally train him, as families have all over this city for decades, in how to take special care in any encounter he has with the police officers who are there to protect him."

De Blasio is at pains to praise and thank police officers for their work. Bratton is doing his share of damage limitation too. "I've worked for eight mayors," he told the press. "This is the best one I've ever worked for." The message doesn't seem to be getting through.

"After those two cops were killed, it became politically expedient to become a friend of the NYPD again," says McGrath. "But he's made a lot of comments that have alienated police, especially the frontline people who are out in their radio cars."

"He has changed his tone about law enforcement, but he had to," says Gonzalez. "When things are said that make people feel that this is a racist police department, you're gonna have a few out there who believe that we're the enemy."

In 1966, when mayor John Lindsay called for a civilian review board, the head of the police union led a rally of off-duty cops outside City Hall, declaring he was "sick and tired of giving in to minority groups, with their whims and their gripes and shouting". In 1975, police published a pamphlet called Welcome To Fear City to protest against proposed departmental cuts, advising tourists not to ride the subway and to stay indoors after dark.

Ironically, relations between the mayor and his police force have deteriorated again at a time of unprecedented success for the NYPD. Last year, there were only 328 reported murders in New York, compared with 2245 in 1990. Crime has dropped in every major US city and there is no clear explanation as to why, but some of the credit must go to the data-driven policies that Bratton introduced.

"I came on this department when there was 2000 homicides a year," says Gonzalez. A lot of these protesters are young people - they weren't even around back then. People have gotten complacent."

McGrath says: "The cops are what put the city back on the map. They've brought billions into the city because people feel safe."

The NYPD has also made ­significant progress in recruiting ethnic minorities. Of the 35,000 cops currently serving the city, more than 9000 are Hispanic and more than 5000 are black.

"The days of the white, Irish Catholic majority are long gone," says Gonzales. "There's always a few bad apples, but you cannot say that this whole agency or its ­policies are racist."

Of course, recruiting black and Latino cops does not make the law suddenly colourblind. In the first seven months of de Blasio's tenure about 137,000 people were arrested for small crimes, 86% of them from ethnic minorities. Of 25 black NYPD officers questioned for a recent poll, all but one said they had been the victim of racial ­profiling when off-duty.

The NYPD has replaced stop-and-frisk with a policy it calls "omnipresence", in which patrol cars are stationed at key corners around the clock, lights flashing. In poor, predominantly African-American neighbourhoods, young men greet each other by bumping elbows rather than slapping palms, to avoid being harassed by police on suspicion of passing drugs hand to hand.

Police are under intense pressure to end their industrial action. Even the New York Post - "New York's Finest have no bigger booster" - has weighed in with an editorial accusing cops of "making a huge mistake" by letting small crimes go. At a police union meeting last Friday, officers heckled Lynch when he called for the mayor to apologise.

There are bound to be further flashpoints. Each time an unarmed African-American is killed by police, the civil rights movement that began in Ferguson is given renewed impetus. On Tuesday, a district attorney in New Mexico announced that two officers would be charged with murder for shooting a homeless man armed with a small knife, another incident captured on video.

In New York, protesters want Pantaleo fired for using a banned chokehold on Garner, something the police union is bound to fight. "The point of the protest is to raise the temperature; raise the stakes for the NYPD and the city," says Foy.

There is also Akai Gurley, killed by a single bullet from a police gun in November as he walked upstairs at the tower block where he lived. Ken Thompson, the Kings County District Attorney, has said he will convene a grand jury to determine whether Gurley's killer, Officer Peter Liang, should face charges.

"This district attorney has a history of prosecuting bad cops successfully," says Foy. "He's not afraid to do so. We have more faith in his grand jury."

But how will de Blasio react if Liang is charged with murder? How will Lynch respond? How many will march if the jury decides not to charge him? Police and protesters are on a collision course, whatever the outcome, and the mayor is stuck in the middle.