The Israeli police raided the most sensitive holy site in Jerusalem before dawn on Wednesday, detaining scores of Palestinians who had barricaded themselves inside a mosque overnight. Armed groups in the Gaza Strip responded by firing rockets toward Israel, which retaliated with airstrikes on military sites in the territory.

The violence at the Aqsa Mosque compound in the Old City, known to Jews as the Temple Mount, came during an already tense period in the region. Officials and diplomats had been warning in recent days that the overlap of the Muslim holy month of Ramadan and the Jewish holiday of Passover, which begins on Wednesday evening, could lead to clashes. The religious observances drive many worshipers to the contested site, which is sacred to both Jews and Muslims.

Brief clashes broke out in other parts of the Old City and the Israeli-occupied West Bank in response to the raid at the mosque. But by midmorning on Wednesday, the unrest had calmed.

Israeli raids on the mosque compound in May 2021 led to an 11-day war between Israel and Hamas — the Islamist Palestinian faction that dominates the Gaza Strip. But tensions on Wednesday did not immediately appear to be moving toward such an all-out confrontation; the rocket fire and airstrikes were contained to a few exchanges and leaders on both sides telegraphed that they were not seeking military escalation.

The latest round of violence began after the Israeli police forced their way into one of the two main prayer halls of a mosque at the holy site. The police said the Palestinians had locked the doors of the prayer hall, the Qibli Mosque, from the inside and barricaded the entrances, hours after the nightly prayers for the holy fasting month of Ramadan, which began two weeks ago.

Twelve Palestinians were injured, according to the Palestinian Red Crescent, and the police said two officers were injured.

Staying overnight at the mosque is banned by the Israeli police except on special occasions such as the end of Ramadan.

In recent weeks, the police had not stringently upheld that ban. But a police spokeswoman said that officers decided to enforce it on Wednesday morning because they feared that, if allowed to stay inside the mosque, Palestinians would confront crowds of Jews who were expected to visit the site a few hours later.

On the eve of Passover, greater numbers of Jews typically visit the site as a form of pilgrimage. To Palestinians, the presence of the Jewish worshipers is considered provocative, partly because many are hard-line activists who hope to build a new temple on the site.

The police said they raided the mosque after prolonged attempts to persuade the worshipers to leave. They said Palestinians also threw stones at officers, and Palestinian news outlets said the police had fired tear gas and sponge-tipped bullets and beaten those inside the mosque.

The police said they had arrested and removed more than 350 Palestinians from the compound; a Palestinian prisoners’ rights group said more than 400 were arrested.

Roughly two hours after the raid, armed groups in Gaza launched at least nine rockets toward Israel, five of which were intercepted by the country’s air defense system. The others landed in open fields, according to the Israeli military.

Hours later, Israeli fighter jets carried out a number of airstrikes on military sites in Gaza, according to Palestinian news media and the Israeli military.

By late morning, Jewish visitors and tourists were walking around the holy site under police protection, and there had been no airstrikes or rockets for several hours.

Mr. Ben-Gvir, Israel’s minister for national security, called for a stronger Israeli response to the rocket fire. But the Israeli military released a statement saying that while it was ready for any scenario, it was “not interested in an escalation.”

Hamas released a statement condemning the Israeli raid and calling for Palestinians to demonstrate in response, but it stopped short of calling for a military confrontation.

The mosque compound is a frequent flashpoint for violence because it is central to both Israeli and Palestinian national narratives.

It was the location of two ancient Jewish temples that were at the heart of Jewish practice in antiquity, and it is considered the most sacred site in Judaism. Centuries after the temples were destroyed, Muslims built a mosque complex there. They believe it is where the Prophet Muhammad ascended to heaven, making it the third-most holy site in Islam.

Israel captured the site from Jordan in the Arab-Israeli war of 1967, and considers it an integral part of its capital. But most of the world considers it to be occupied territory under international law.

For decades, Israel prevented Jews from praying there to avoid aggravating tensions. In recent years, however, the Israeli police have allowed Jews to quietly worship at the edge of the compound. That has angered many Palestinians and Muslim-majority states in the region, and amplified Palestinian anxieties about growing Jewish influence at the site.

In recent days, those fears were exacerbated by efforts by hard-line Jewish activists to sacrifice a goat at the compound to mark the start of the weeklong Jewish holiday of Passover.

The Israeli police have repeatedly said they would not allow such a sacrifice, but the calls aggravated Palestinian concerns about a Jewish takeover of the compound, particularly as more Jews were expected to mark Passover by praying there.

In response, Palestinians had urged worshipers to come to the mosque on the compound and stay overnight to pray, a tradition that is practiced especially during Ramadan.

On Saturday, the Israeli police shot and killed a Palestinian citizen of Israel at one of the entrances of the mosque compound. The police said the man seized and fired a police officer’s gun after being stopped for questioning. But Palestinian news outlets said the man had been killed during a scuffle after intervening to prevent the assault of a Palestinian woman.

Hiba Yazbek contributed reporting from Jerusalem and Gabby Sobelman from Rehovot, Israel.