Ray is one of the oldest cities of Iran. About 300 BC, one of the successors of Alexander (Solukus) named Ray as "Oriyoos". Thereafter the Parthians named the same "Arsakia" and "Arshakiyeh". During the reign of the Sassanids ‘Ray’ found its current name.In the Islamic era this city was the ruling center of ‘Bani Omayeh’ clan and during the Mongol and Teimoorian conquests claimed to be an area of invasion for several times. Ancient relics of this city which are mentioned in this text indicate the historical antiquity of Ray.
Ray is richer than many other ancient cities in the number of its historical monuments, among which one might refer to the 3000-year-old Gebri castle, the 5000-year-old Cheshmeh Ali hill, the 1000-year-old Bibi Shahr Banoo tomb and Shah Abbasi caravanserai. It has been home to pillars of science like Rhazes.
Rey was one of the capital cities of the Seljuq Empire in the 11th century. In the 13th century after the Mongol conquest the town was severely damaged and it gradually lost its importance in the presence of nearby Tehran.
There is also a shrine there, dedicated to commemorate Princess Shahr Banu, eldest daughter of the last ruler of the Sassanid Empire. She gave birth to Ali ibn Husayn Zayn al-Abidin, the fourth holy Imam of the Shia faith. This was through her marriage to Husayn ibn Ali, the grandson of Muhammad, the prophet of Islam. A nearby mountain is also named after her. However, some sources attribute the shrine to the goddess of water and fertility, Anahita, claiming it was renamed in Islamic times to protect it from any possible harm after the conversion of Iranians to Islam.
In the middle of the 19th century, Ray was described as a place of ruins, the only settlement being around the shrine of Abdol Azim. Being the only important pilgrimage site in vicinity to the royal court in the new capital Tehran brought more people to visit the shrine and a major restoration was sponsored by the court. Thus Ray was the first place in Iran to be connected to the capital by a railroad in 1888.