New York (AFP) - President Donald Trump waded into a debate about police restraint Thursday, after two videos went viral showing officers being doused in water in New York.

The separate incidents occurred during a heat wave that swept large regions of the United States last weekend bringing record temperatures.

In one of the clips, two officers walking through the Brooklyn area of the city were seen being drenched with water by locals.

Officers were also soaked as they responded to a call in Harlem. One of them was hit on the head with a bucket as onlookers cheered.

"We love our Law Enforcement Officers all around this great Country. What took place in NYC with water being tossed on NYPD officers was a total disgrace," Trump tweeted.

He then took a dig at New York Mayor Bill de Blasio, a candidate for the 2020 Democratic presidential nomination.

"It is time for @NYCMayor @BilldeBlasio to STAND UP for those who protect our lives and serve us all so well...," Trump wrote.

The incidents, which De Blasio and New York police chiefs also condemned, sparked a debate about how much abuse officers should put up with without making an arrest.

Some people commented online, praising them for not inflaming the situation; others said they should not have tolerated the ridicule.

Trump ally Rudy Giuliani, who adopted a zero-tolerance policy towards even the most minor infractions during his tenure as Republican mayor, accused De Blasio of fostering "disrespect" for the police.

De Blasio hit back on Twitter, claiming his administration had achieved record-low crime rates "because we're bridging the divide between police and communities."

Police say they have since arrested three men in connection with the soakings and are searching for more suspects.

The incidents come at a time when tensions are high between police and parts of the city following a decision not to press federal charges against an officer accused of placing a black man in a banned choke hold just before he died.

The government said earlier this month that there was "insufficient evidence" that officer Daniel Pantaleo broke the law or contributed to the death of Eric Garner during an arrest on July 17, 2014.

The move effectively closed the five-year-old case that fueled national "Black Lives Matter" protests calling for police to be held accountable for the deaths of unarmed African-Americans in custody or facing arrest.