Earlier, companies of Israeli police streamed on to the hilltop compound known to Muslims as the Haram al-Sharif and to Jews as the Temple Mount, to try to quell what Micky Rosenfeld, an Israeli police spokesman, called Muslims rioting over the repair work.
Clouds of tear gas rose up at the holy site and stun grenades set off sharp booms.
Twenty Palestinians were treated for injuries, a Palestinian medical source said. Witnesses said police arrested various protesters.
A doctor treating some of the injured, Dr Khalil el-Baba, said Israeli officers fired rubber bullets at protesters, but police denied that.
Rosenfeld said: "Seventeen policemen were hurt, nine of them taken to hospital. Seventeen Arab rioters were arrested and police are in full control.
"Around 150 worshippers are now leaving in peace and quiet after dialogue between police and Muslim representatives."
Palestinians and Israeli police in riot gear could be seen running across the open esplanade in live television footage before Rosenfeld insisted that the situation was under full control.
About 90 minutes after the Israeli policemen went in, the protesters began to leave at the conclusion of negotiations between officers and Muslim representatives, negotiators said.
Maher al-Ami, a journalist for Jerusalem's al-Quds newspaper, said: "We were at Friday prayers and suddenly they [the Israelis] began to shout and throw stun grenades."
Adnan Husseini, the director of the Muslim organisation Waqf, said: 'We are surrounded. There is one gate still open but they [the Israelis] won't let anyone leave."
Call for calm
Jacky Rowland, Al Jazeera's correspondent, said the sheikh issued calls for calm came over the mosque's loudspeaker system, normally used for the call to prayer.
Israel had deployed 3,000 police officers around Jerusalem's Old City in advance of Muslim prayers at the mosque compound, amid widespread Arab anger over Israeli excavation work nearby.
Ilan Franco, Jerusalem police chief, said officers were posted on Friday amid "intelligence indications" that disturbances could erupt.
Arab states say the work could damage the foundations of the mosque, the third holiest site in Islam.
Israeli authorities say the building work, begun on Tuesday, is being carried out to replace a centuries-old ramp 60 metres away.
'Day of anger'
A day of "anger" on the Muslim day of rest had been called by Tayssir al-Tamimi, the Palestinian chief justice, who on Tuesday called for "all Palestinians to go and protect al-Aqsa against Israeli plans that aim to destroy the mosque".