Hamburg has become Germany's first city to recognise Islamic holidays, a move meant to encourage the integration of a religious minority often vilified by opponents of immigration.
Muslim employees and students will be allowed days off to celebrate their holidays and Islamic classes will be allowed in state schools, authorities and Islamic groups said after negotiations lasting five years.
"We hope that the introduction of Muslim religious classes in the northern city-state will be a signal for the other fifteen German states," said Daniel Abdin from Hamburg's council of Islamic communities. "This agreement is an important step towards a recognition of Islam in the country."
The agreement will come into force next year, the first of this kind in a country home to some 4 million Muslims, about half of whom have German citizenship.
The total population is around 82 million in Germany where religious and ethnic tolerance is a sensitive issue.
Federal conservative lawmaker Volker Kauder, a close ally of Chancellor Angela Merkel, said earlier this year that Islam was not part of Germany's tradition and identity.
A court in Cologne banned circumcision on young boys in July, sparking criticisms from the Muslim and Jewish communities.
Muslim groups in Hamburg, representing some 150,0000 Muslims, said the agreement was a historic sign of acceptance.
"Muslims consider Hamburg their home," said Zekeriya Altug, from Hamburg's Turkish-Islamic Union of the Institute for Religion.