Legend of Cheraman Perumals
The legend of Cheraman Perumals is the medieval tradition associated with the Cheraman Perumals (Chera kings) of Kerala. The sources of the legend include popular oral traditions and later literary compositions. The time of origin of the legend is not known to scholars. It seems the legend once had a common source well known to all Kerala people. The validity of the legend as a source of history once generated much debate among south Indian historians. The legend is now considered as "an expression of the historical consciousness rather than as a source of history". The legend of the Cheraman Perumals exercised significant political influence in Kerala over the centuries. 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). Popular written versions of the legend are infamous for inconsistencies and contradictions (in names of the kings and dates). Even the dates of their compositions are problematic. The Cheraman Perumals mentioned in the legend can be identified with the Chera Perumal rulers of medieval Kerala (c. 8th - 12th century AD). Sources of the legend  
Different written versions of the legend can be found in several literary sources. Most versions contain interpolations and omissions in favour of some special interests and communities (religions and castes). Keralolpatti chronicle
 Duarte Barbosa (1510)
 Joas de Barros (16th century)
 Diogo de Coute (1610)
 Lusiad
 Sheik Zeinuddin (c. 1583)
 Canter Visscher (c. 1723)
 Van Adriaan Moens (1781)
 H. H. Wilson, Mackenzie Collection
 Jonathan Duncan (1798)
 Francis Buchanan (1807)
 William Logan (1898)
 G. A. Kohut (1897)
 C. A. Innes (1908)
 E. Thurston (1909)
 Calicut Granthavari
 Cochin Granthavari
 S. N. Sadasivan (2000)

Major themes 
The Cheraman Perumals were the kings of Kerala/Chera kingdom. The first Cheraman Perumal was "brought" from a country east of the Ghats to Kerala by Nambudiri Brahmins (four select Brahmin settlements were empowered to choose a khastriya king). Sister of the first Cheraman Perumal was married to Brahmin and it was decided that the son/daughter would be a Kshatriya (and the successor to the throne). The Brahmins arranged that each Perumal should rule for twelve years. Cheraman Perumals 
The Cheraman Perumals of the legend are generally associated with the establishment the Kollam Era (Malayalam Era), inauguration of the Onam Festival, introduction of the matrilineal system of inheritance in Kerala, settlement of different castes in Kerala, and foundation several temples, churches and mosques in Kerala. The following is a list of Cheraman Perumals found in the tradition. The last Cheraman Perumal 

Rayar, the overlord of the Cheraman Perumal (Kulasekharan) 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 and Manichchan and Vikkiran of Eranad). The Cheraman Perumal was assured by the Eradis 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). The last Cheraman Perumal divided the Kerala or Chera kingdom among his chieftains (kingsfolk) and disappeared mysteriously. The Kerala people never more heard any tidings of him. The Eradis, or the later kings of Calicut, who were left out in the cold during the allocation of the land, was granted the Cheraman Perumal's sword (with the permission to "die, and kill, and seize"). Accounts of legacy
The last Cheraman Perumal Rama Kulasekhara was believed to have disappeared under strange circumstances in 1122 A.D. which prevented the nomination of another leader, in consequence of which the kingdom broke into pieces. Other accounts say, Rama Varma Kulasekhara divided his empire among his own and his sister's children, and among other relatives. He then embraced Islam. On some account, Rama Kulasekhara denounced his throne and went to Arabia in the company of some Muslim traders. He is said to have become a convert to Islam and died at a place called Sapher in Arabia. The fact that the old Madayi Mosque was built in 1124 A.D., only two only two years after the disappearance of the Perumal, makes his conversion and emigration to Arabia quite possible, although there are differences of opinion. The story of Thajuddin Cheraman Perumal 
According to the Cheraman Juma Mosque: "Once, the  Tamil King Cheraman Perumal, possibly named Baskara Ravi Varma, was walking with one of his favored queens for a late-night stroll in the palace garden where he lived with her. It was during this stroll that he witnessed the splitting of the moon. However, no one else in the palace or the rest of the Indian subcontinent saw this event. Shocked by the splitting of the full moon, which occurred many years before Muslims' migration to Medina, Cheraman hurried back to the capital of the Chera Kingdom. He wanted to consult his chain of Hindu astronomers, known as Siddhars, to determine the exact time of this lunar phenomenon. According to the Hindu mathematical system, the astronomers should have been able to forecast the lunar eclipse. Nevertheless, the precise astronomical date and time of this event remain uncertain. Therefore, when some Arab merchants from the Banu Quraysh tribe visited Cheraman's palace for unknown reasons, he took the opportunity to inquire about this incident that should have occurred in the Eastern sky. The Hindu astronomers should have been able to calculate the exact time and coordinates of this astronomical event. At their request, the King embarked on a pilgrimage to pray at the temple of the Arabian Moon-god Hubal and the Shrine of Quraysh idols in Mecca. During his visit to the Kaaba, Cheraman had the opportunity to meet the Islamic prophet Muhammad and gifted ginger pickles for Muhammad and his companions. He conversed with Muhammad in Arabic, and it was during this encounter that Bilal, a companion of Muhammad, guided Cheraman to convert to Islam. As a result, Muhammad bestowed upon him the name Tajuddin, Thajuddin, or Thiya-aj-Addan, which means "crown of faith" thus, becoming the first Indian Muslim". The king then remained in the services of Muslims. Nearly 120 years later his letters arrived to his kingdom in Kerala. Subsequently, in the year 748 CE, Malik Deenar embarked upon the mission of propagating Islam, and over time, the Hindu kingdom in Kerala began to gradually embrace the teachings and principles advocated by Malik bin Deenar. Al-Tabari of the 9th century in his Firdousul Hikma and Ferishta in his Tarikh Ferishta agree with this. This story is found in Tuhfat Ul Mujahideen, a Muslim account recorded by Sheikh Zeinuddin, it states that this incident happened two centuries later after the time of Muhammad. According to the Legend of the Cheraman Perumal Mosque, the first Indian mosque was built in 508-68 AD at Kodungallur with the mandate of the last the ruler (the Cheraman Perumal) of Chera dynasty, who left from Dharmadom to Mecca and converted to Islam during the lifetime of Prophet Muhammad (c. 570–632). According to Qissat Shakarwati Farmad, the Masjids at Kodungallur, Kollam, Madayi, Barkur, Mangalore, Kasaragod, Kannur, Dharmadam, Panthalayani, and Chaliyam, were built during the era of Malik Dinar, and they are among the oldest Masjids in Indian Subcontinent. The story goes that Cheraman Perumal arrived in Arabia with a gift of ginger pickles for Muhammad and his companions and converted to Islam "at the feet of Prophet Muhammad". According to historian M.G.S. Narayanan, "there is no reason to reject the tradition that the last Chera king embraced Islam and went to Mecca, since it finds its place not only in Muslim chronicles, but also in Hindu brahmanical chronicles like the Keralolpatti, which need not be expected to concoct such a tale which in no way enhances the prestige of the Brahmins or Hindu population." But S. N. Sadasivan, in his book A Social History of India, argues that it was the king of Maldives, Kalimanja, who converted to Islam. Mali, which was known to seafarers then, might have been misunderstood as Malabar (Kerala) and this might have given rise to the tale of Tajuddeen in the Cochin Gazetteer. 