The legend of Cheraman Perumals is the medieval tradition associated with the "Cheraman Perumals" (literally the Chera kings) of Kerala. The validity of the legend as a source of history once generated much debate among South Indian historians. The legend was used by Kerala chiefdoms for the legitimation of their rule (most of the major chiefly houses in medieval Kerala traced its origin back to the legendary allocation by the Perumal). According to the legend, "Rayar", the overlord of the Cheraman Perumal in a country east of the Ghats, invaded Kerala during the rule of the last Perumal. To drive back the invading forces the Perumal summoned the militia of his chieftains (like "Udaya Varman Kolathiri", "Manichchan", and "Vikkiran" of Eranad). The "Cheraman Perumal" was assured by the "Eradis" (chief of Eranad) that they would take a fort established by the "Rayar". The battle lasted for three days and the "Rayar" eventually evacuated his fort (and it was seized by the Perumal's troops). Then the last "Cheraman Perumal" divided Kerala or Chera kingdom among his chieftains and disappeared mysteriously. The Kerala people never more heard any tidings of him. The "Eradis" of Nediyiruppu, who later came to be known as the Zamorins of Kozhikode, who were left out in cold during allocation of the land, was granted the "Cheraman Perumal" sword (with the permission to "die, and kill, and seize"). According to the Cheraman Juma Mosque and some other narratives, "Once a "Cheraman Perumal" probably named Ravi Varma was walking with his queen in the palace, when he witnessed the Splitting of the moon. Shocked by this, he asked his astronomers to note down the exact time of the splitting. Then, when some Arab merchants visited his palace, he asked them about this incident. Their answers led the King to Mecca, where he met Islamic prophet Muhammad and converted to Islam. Al-Tabari of 9th century in his "Tarikh Ferishta", states the legend.