JERUSALEM — Masked Palestinian youths clashed with Israeli police in Jerusalem’s Al Aqsa Mosque compound on Sunday, as Jews marked an annual day of mourning commemorating the destruction of two ancient temples believed to have once stood at the holy site.

The Palestinians had barricaded themselves in the mosque, the police said in a statement. They said the youths were preparing for a confrontation meant to prevent Jews from visiting the site, revered by Muslims as the Noble Sanctuary and by Jews as the Temple Mount.

Clashes broke out in the courtyard as Palestinians threw stones, fired flares and sprayed an unidentified liquid at the police, who responded with stun grenades and tear gas. After some rioters ran back inside the mosque, the police said, Israeli forces entered a few yards into it to close the doors and restore calm. Three Palestinians were arrested, the police said.

Tensions had been building before the Jewish day of fasting and after an Orthodox Jewish woman visiting the site hurled an insult in Arabic about the Prophet Muhammad at a group of Muslim women protesting the presence of Jews there.