JERUSALEM — Hamas militants fired dozens of rockets into Israel on Monday, including a barrage that set off air raid sirens as far away as Jerusalem, after hundreds of Palestinians were hurt in clashes with Israeli police at a flashpoint religious site in the contested holy city.

The rocket fire drew heavy Israeli retaliation in the Gaza Strip. Health officials said at least 20 people, including nine children, were killed in fighting, making it one of the bloodiest days of battle between the bitter enemies in several years.

The fighting escalated already heightened tensions throughout the region following weeks of confrontations between Israeli police and Palestinian protesters in Jerusalem. Those confrontations, focused around a disputed hilltop compound in Jerusalem’s Old City, have threatened to spark a wider conflict.

Prime Minister Benjamin Netanyahu accused Hamas of crossing a “red line” with the rocket attack on Jerusalem, some 60 miles north of Gaza, and promised a tough response.

“Whoever attacks us will pay a heavy price,” he said, warning that the fighting could “continue for some time.”

In Washington, State Department spokesman Ned Price condemned “in the strongest terms” the rocket fire on Israel and called on all sides to calm the situation.

“More broadly, we’re deeply concerned about the situation in Israel, the West Bank and the Gaza Strip, including violent confrontations in Jerusalem,” he said.

A diplomatic official said that the United Nations, Egypt and Qatar, which frequently mediate between Israel and Hamas, were all trying to halt the fighting. He spoke on condition of anonymity because he was not authorized to discuss the issue with the media.

The Israeli military said well over 50 rockets were fired into Israel throughout the evening, most of them aimed at southern Israeli towns near the border.

Lt. Col. Jonathan Conricus, a military spokesman, said six rockets were aimed at Jerusalem in what was believed to be the first rocket attack on the city since a 2014 war.

Shortly after the sirens sounded, explosions could be heard in Jerusalem. One rocket fell on the western outskirts of the city, lightly damaging a home and causing a brush fire. The Israeli army said one rocket was intercepted and the others fell in open areas.

Israel was responding with airstrikes on Hamas targets throughout Gaza. The army said rocket launchers and eight militants had been targeted.

In Gaza, health officials reported a total of 20 deaths, including nine children.

It did not provide a breakdown, but at least seven members of a family, including three children, were killed in a blast in the northern town of Beit Hanoun. It was not immediately clear if the blast was caused by an airstrike or errant rocket.

The Israeli army said an Israeli civilian in the country’s south suffered mild injuries when a vehicle was struck by an anti-tank missile from Gaza.

Abu Obeida, spokesman for Hamas’ military wing, said the attack on Jerusalem was a response to what he called Israeli “crimes and aggression” in the city. “This is a message the enemy has to understand well,” he said.

He threatened more attacks if Israeli forces re-enter the Al-Aqsa Mosque compound — an area known to Muslims as Noble Sanctuary and to Jews as Temple Mount — or carry out planned evictions of Palestinian families from an east Jerusalem neighborhood.

Earlier, Israeli police firing tear gas, stun grenades and rubber bullets clashed with stone-throwing Palestinians at the iconic compound, which is Islam’s third-holiest site and considered Judaism’s holiest. Tensions at the site have been the trigger for prolonged bouts of violence in the past, including the last Palestinian intifada, or uprising.

More than a dozen tear gas canisters and stun grenades landed in the mosque as police and protesters faced off inside the walled compound that surrounds it, said an Associated Press photographer at the scene. Smoke rose in front of the mosque and the golden-domed shrine on the site, and rocks littered the nearby plaza. Inside one area of the compound, shoes and debris lay scattered over ornate carpets.

More than 300 Palestinians were hurt, including 228 who went to hospitals and clinics for treatment, according to the Palestinian Red Crescent. Israeli police said 21 officers were hurt, including three who were hospitalized. Israeli paramedics said seven Israeli civilians were also hurt.

In an apparent attempt to avoid further confrontation, Israeli authorities changed the planned route of a march by ultra-nationalist Jews through the Muslim Quarter of the Old City to mark Jerusalem Day, which celebrates Israel’s capture of east Jerusalem.

Monday’s confrontation was the latest after weeks of almost nightly clashes between Palestinians and Israeli troops in the Old City of Jerusalem during the Muslim holy month of Ramadan. The month tends to be a time of heightened religious sensitivities.