Keralam was first epigraphically recorded as Cheras (Keralaputra) in a 3rd-century BCE rock inscription by the Mauryan emperor Ashoka of Magadha. It was mentioned as one of four independent kingdoms in southern India during Ashoka's rule, the others being the Cholas, Pandyas and Satyaputras. The Cheras transformed Kerala into an international trade centre by establishing trade relations across the Arabian Sea with all major Mediterranean and Red Sea ports as well those of Eastern Africa and the Far East. The dominion of Cheras was located in one of the key routes of the ancient Indian Ocean trade. The early Cheras collapsed after repeated attacks from the neighboring Cholas and Rashtrakutas.

In the 8th century, Adi Shankara was born in Kalady in central Kerala. He travelled extensively across the Indian subcontinent founding institutions of the widely influential philosophy of Advaita Vedanta. The Cheras regained control over Kerala in the 9th century until the kingdom was dissolved in the 12th century, after which small autonomous chiefdoms, most notably the Kingdom of Kozhikode, arose. The ports of Kozhikode and Kochi acted as major gateways to the western coast of medieval South India for several foreign entities. These entities included the Chinese, the Arabs, the Persians, various groups from Eastern Africa, various kingdoms from Southeast Asia including the Malacca Sultanate, and later on, the Europeans.

In the 14th century, the Kerala school of astronomy and mathematics was founded by Madhava of Sangamagrama in the Kingdom of Tanur. Some of the contributions of the school included the discovery of the infinite series and taylor series of some trigonometry functions.

In 1498, with the help of Gujarati merchants, Portuguese traveler Vasco Da Gama established a sea route to Kozhikode by sailing around the Cape of Good Hope, located in the southernmost region of Africa. His navy raised Portuguese forts and even minor settlements, which marked the beginning of European influences in India. European trading interests of the Dutch, French and the British took center stage in Kerala.

In 1741, the Dutch were defeated by Travancore king Marthanda Varma. After this humiliating defeat, Dutch military commanders were taken hostage by Marthanda Varma, and they were forced to train the Travancore military with modern European weaponry. This resulted in Travancore being able to defend itself from further European aggression. By the late 18th century, most of the influence in Kerala came from the British. The British crown gained control over Northern Kerala through the creation of the Malabar District. The British also allied with the princely states of Travancore and Cochin in the southern part of the state.

When India declared independence in 1947, Travancore originally sought to establish itself as a fully sovereign nation. However, an agreement was made by the then King of Travancore Chithira Thirunal Balarama Varma to have Travancore join India, albeit after many rounds of negotiation. The Malabar District and the Kingdom of Cochin were peacefully annexed into India without much hassle. The state of Kerala was created in 1956 from the former state of Travancore-Cochin, the Malabar district and the Kasaragod taluk of South Canara District of Madras state. The state is called Keralam in Malayalam, due to its grammatical addition of Anusvara.

Other names The term Malabar has historically been used in foreign trade circles as a general name for Kerala. In earlier times, the term Malabar had also been used to denote Tulu Nadu and Kanyakumari which lie contiguous to Kerala on the southwestern coast of India, in addition to the modern state of Kerala. The people of Malabar were known as Malabars. From the time of Cosmas Indicopleustes (6th century CE) itself, the Roman sailors used to call Kerala as Male. The first element of the name, however, is attested already in the Topography written by Cosmas Indicopleustes. This mentions a pepper emporium called Male, which clearly gave its name to Malabar ('the country of Male'). The name Male is thought to come from the Dravidian word Mala ('hill'). Al-Biruni (AD 973–1048) must have been the first writer to call this state Malabar. Author such as Al-Baladhuri mention Malabar ports in their works. The Arab writers had called this place Malibar, Manibar, Mulibar, and Munibar. Malabar is reminiscent of the word Malanad which means the land of hills. According to William Logan, the word Malabar comes from a combination of the Dravidian word Mala (hill) and the Persian/Arabic word Barr (country/continent).

Traditional sources

Mahabali Perhaps the most famous festival of Kerala, Onam, is deeply rooted in Kerala traditions. Onam is associated with the legendary king Mahabali (Maveli), who according to tradition and Puranas, ruled the Earth and several other planetary systems from Kerala. His entire kingdom was then a land of immense prosperity and happiness. However, Mahabali was tricked into giving up his rule, and was thus overthrown by Vamana (Thrikkakkarayappan), the fifth Avatar (earthly incarnation) of Lord Vishnu. He was banished from the Earth to rule over one of the netherworld (Patala) planets called Sutala by Vamana. Mahabali comes back to visit Kerala every year on the occasion of Onam.

Other texts The oldest of all the Puranas, the Matsya Purana, sets the story of the Matsya Avatar (fish incarnation) of Lord Vishnu, in the Western Ghats. The earliest Sanskrit text to mention Kerala by name as Cherapadah is the Aitareya Aranyaka, a late Vedic work on philosophy. It is also mentioned in both the Ramayana and the Mahabharata.

Parasurama and Cenkuttuvan There are legends dealing with the origins of Keralam geographically and culturally. One such legend is the retrieval of Kerala from the sea, by Parasurama, a warrior sage. It proclaims that Parasurama, an Avatar of Mahavishnu, threw His battle axe into the sea. As a result, the land of Kerala arose, and thus was reclaimed from the waters. This legend shares parallels with an earlier legend where Chera King Vel Kezhu Kuttavan, who when enraged, threw his axe into the sea and caused it to retreat.

Ophir

Ophir, a region mentioned in the Bible, famous for its wealth, is often identified with some coastal areas of Kerala. According to legend, the King Solomon received a cargo from Ophir every three years (1 Kings 10:22) which consisted of gold, silver, sandalwood, pearls, ivory, apes, and peacocks. A Dictionary of the Bible by Sir William Smith, published in 1863, notes the Hebrew word for parrot Thukki, derived from the Classical Tamil for peacock Thogkai and Cingalese Tokei, joins other Classical Tamil words for ivory, cotton-cloth and apes preserved in the Hebrew Bible. This theory of Ophir's location in Tamilakam is further supported by other historians. The most likely location on the coast of Kerala conjectured to be Ophir is Poovar in Thiruvananthapuram District (though some Indian scholars also suggest Beypore as possible location). The Books of Kings and Chronicles tell of a joint expedition to Ophir by King Solomon and the Tyrian king Hiram I from Ezion-Geber, a port on the Red Sea, that brought back large amounts of gold, precious stones and 'algum wood' and of a later failed expedition by king Jehoshaphat of Judah. The famous 'gold of Ophir' is referenced in several other books of the Hebrew Bible.

Cheraman Perumal

The legend of Cheraman Perumals is the medieval tradition associated with the Cheraman Perumal (literally the Chera kings) of Kerala. The Cheraman Perumals mentioned in the legend can be identified with the Chera Perumal rulers of medieval Kerala (–12th century CE). 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's 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 the Islamic prophet Muhammad and converted to Islam. Muhammad named him Tajuddin or Thajuddin or Thiya-aj-Addan meaning "crown of faith". The king then wrote letters to his kingdom to accept Islam and follow the teachings of Malik bin Deenar". It is assumed that the first recorded version of this legend is an Arabic manuscript of anonymous authorship known as Qissat Shakarwati Farmad. The 16th century Arabic work Tuhfat Ul Mujahideen authored by Zainuddin Makhdoom II of Ponnani, as well as the medieval Malayalam work Keralolpathi, also mention about the departure of last Cheraman Perumal of Kerala into Mecca.

Prehistory

A substantial portion of Kerala including the western coastal lowland and the plains of midland may have been under the sea in ancient times. Marine fossils have been found in an area near Changanassery, thus supporting the hypothesis. Archaeological studies have identified many Mesolithic, Neolithic and Megalithic sites in the eastern highlands of Kerala mainly centred around the eastern mountain ranges of Western Ghats. Rock engravings in the Edakkal Caves, in Wayanad date back to the Neolithic era around 6000 BCE. These findings have been classified into Laterite rock-cut caves (Chenkallara), Hood stones (Kudakkallu), Hat stones (Toppikallu), Dolmenoid cists (Kalvrtham), Urn burials (Nannangadi) and Menhirs (Pulachikallu). The studies point to the indigenous development of the ancient Kerala society and its culture beginning from the Paleolithic age, and its continuity through Mesolithic, Neolithic and Megalithic ages. However, foreign cultural contacts have assisted this cultural formation. The studies suggest possible relationship with Indus Valley civilization during the late Bronze Age and early Iron Age.

Archaeological findings include dolmens of the Neolithic era in the Marayur area. They are locally known as "muniyara", derived from muni (hermit or sage) and ara (dolmen). Rock engravings in the Edakkal Caves in Wayanad are thought to date from the early to late Neolithic eras around 5000 BCE. Historian M. R. Raghava Varier of the Kerala state archaeology department identified a sign of "a man with jar cup" in the engravings, which is the most distinct motif of the Indus valley civilisation.

Classical period

Early ruling dynasties