The Constitution of Medina, written on behalf of the Islamic prophet Muhammad in 622 CE, outlines the rights and duties of the people living in the city of Medina (present-day Saudi Arabia).  The document also regulates relations between Muslims and other communities on the basis of religion (as opposed to ethnicity or tribal affiliation).

The constitution protects all inhabitants of Medina, regardless of religion, and explicitly states that Jews and Muslims can practice their religions freely.  Many historians consider the Constitution of Medina to be the first document in history to establish religious freedom as a right (though earlier documents, such as the Cyrus Cylinder, also mention religious freedom).

Door of Al-Masjid an-Nabawī (The Prophet's Mosque) in Medina (via Medium)

Door of Al-Masjid an-Nabawī (The Prophet's Mosque) in Medina (via Medium)