Palestinian Muslims wave a national flag and flash the victory gesture in front of the Dome of the Rock. (Ahmad Gharabli/Agence France-Presse via Getty Images)

Palestinians declared a hard-won victory Thursday against what they saw as an attempt by Israel to limit access at their holiest site, the al-Aqsa Mosque compound.

Israel installed metal detectors at the gates to the sensitive shrine after three Israeli Arab gunmen killed two Israeli police officers there on July 14. Now, nearly two weeks later, the detectors and other extra security devices are being dismantled.

Jerusalem’s grand mufti, Mohammed Hussein, a spiritual leader and custodian of the mosque, urged Muslims on Thursday to return to their shrine for worship, declaring the crisis over.

Worshipers had refrained from entering the compound, praying on the streets outside instead.

The esplanade on which al-Aqsa stands is considered holy by both Muslims, who call it the Noble Sanctuary, and by Jews, who refer to it as the Temple Mount.

With news of the victory, Muslims flooded the 37-acre holy complex singing victory songs and chanting “God is great.” A group of youths scaled the mosque’s stone wall and planted a Palestinian flag on top.

Within minutes, Israeli police officers followed in their path and took the flag down. Police spokesman Micky Rosenfeld said worshipers started to throw rocks at security forces, as well as at Jewish worshipers praying at the adjacent Western Wall.

The cheers of joy were quickly replaced with the crack of stun grenades, and the air filled with smoke as Israeli police shot tear-gas canisters inside the mosque compound. At least 40 worshipers and 10 Israeli police officers were reported injured.

Clashes continued at the site through the evening.

“The police will respond with a tough hand to any disturbances,” the spokesman said in a statement.

Israeli security officials said they were bracing for huge crowds during Friday prayers at al-Aqsa, the scene for frequent clashes not only Thursday but also over the decades.

Jerusalem Police Chief Yoram Halevi warned Palestinian protesters that his officers will respond to provocations with force.

“No one should try to test us tomorrow,” Halevi told reporters. “If there are people who try to disturb the peace, to harm police or citizens, they should not be surprised. There will be casualties and people injured.”

Still, the Palestinians celebrated what they saw as a win, after Israel removed the new security measures.

Abu Abad al-Qaq, 49, a building contractor from Silwan in East Jerusalem who attended the protests at the Lions’ Gate entrance in the Old City, said: “This was a big miscalculation by the Israelis, who underestimated the power of the Jerusalem street, which has surprised everybody, even the Palestinian leadership.”

Ibrahim Awad Allah, a top official in the Islamic Waqf, which serves as custodian of the holy site, under the control and patronage of the king of Jordan, said the victory at the site was a “message to the Israeli occupation that their arrogance failed them.”

“Everything that has been imposed by the Israelis, all of it, has been removed,” he said, calling such a withdrawal both rare and sweet. “This is a victory.”

Beginning with the Palestinian attack that left the Israeli police officers dead on July 14, the turmoil over access to the mosque has left 15 people dead, including three Israelis fatally stabbed in their home in a West Bank settlement and two Jordanians, one an alleged assailant and the other a bystander, shot by a security guard at the Israeli Embassy in Amman, Jordan.

The decision by Israeli Prime Minister Benjamin Netanyahu and his government to back down over the increased security measures, after days of vowing that the metal detectors would stay for security reasons, was seen by Israelis and Palestinians as a capitulation.

Some Israelis said Netanyahu did the right and smart thing by de-escalating the tension, but members of his government criticized him for what they saw as weakness in the face of Palestinian opposition and violence. 

“Israel comes out weakened from this crisis,” hard-line minister Naftali Bennett said on Israel Army Radio on Thursday morning. “Instead of sending a message about Israel’s sovereignty on the Temple Mount, it sent a message that Israel’s sovereignty can be questioned.”

At the outbreak of the crisis, Public Security Minister Gilad ­Erdan said it was up to Israel to decide security protocol for the site. 

Israel’s minister for national security and foreign affairs, Tzachi Hanegbi, said earlier this week in a radio interview that Israel would not give in to threats at the Temple Mount.

“If you are threatening us that you won’t enter the Mount, then don’t enter the Mount. Put down prayer mats and pray wherever you want. If you want to pray on the Mount, pass through the checkpoints just as I had to do at the Vatican a few weeks ago, just as we all have to at the Western Wall,” he said.

He said that Israel was the sovereign power in Jerusalem and on the Temple Mount.

But the ongoing protests, some peaceful and some violent, have challenged that. 

Over the past week and a half, Palestinian Muslim worshipers have laid their prayer mats down on the street outside the mosque compound, stirring emotions in the wider Arab world and causing tensions between Israel and one of its closest Muslim allies, Jordan.

In a Facebook post Wednesday, Netanyahu vowed to shut down the Jerusalem bureau of Al Jazeera, the Qatar-based news network, for broadcasting images of what he called incitement.

Netanyahu’s bureau declined to give specific examples of the Al Jazeera content that might have stoked tensions.

Asked for a specific example, a communications adviser in Netanyahu’s office suggested that reporters scroll through Google.

Last week, the channel published a short video clip showing an Israeli police officer kicking a Palestinian kneeling on a prayer mat for worship. Netanyahu’s office did not dispute the veracity of the clip.

 It was this image and others that spurred Omar al-Abed, a 19-year-old Palestinian, to fatally stab three Israelis in the settlement of Halamish on July 21, his father told The Washington Post this week. 

 Netanyahu called the teen a “beast” and said he was “incited by Jew hatred.”

The attack, which left a 70-year-old Israeli grandfather and his two adult children lying in a pool of blood in the family’s kitchen, drew angry reactions from Israeli leaders, with several calling for Israel to use the death penalty. The attacker was shot but only lightly wounded.

 Palestinians say the Israelis are also guilty of inciting violence.

 They point to statements by Israeli parliament member Oren Hazan, who posted a video on his Facebook account saying that he wanted to demolish Abed’s home and “execute” his family.

“I want to be honest without sounding too extreme, but if it was up to me, I would’ve gone to the terrorist’s house yesterday, grabbed him and his whole family and executed them all together,” said Hazan, who is a member of Netanyahu’s Likud party.

 Sufian Taha contributed to this report.