The history of the Malay language can be divided into five periods: Old Malay, the Transitional Period, the Malacca Period (Classical Malay), Late Modern Malay, and modern Malay. It is not clear that Old Malay was actually the ancestor of Classical Malay, but this is thought to be quite possible.
Old Malay was influenced by Sanskrit, the lingua franca of Hinduism and Buddhism. The Sanskrit loanwords can be found in Old Malay vocabulary. The earliest known stone inscription in the Old Malay language was found in Sumatra, written in Pallava variant of Grantha script and dates back to 7th century – known as Kedukan Bukit Inscription, it was discovered by the Dutchman M. Batenburg on 29 November 1920, at Kedukan Bukit, South Sumatra, on the banks of the River Tatang, a tributary of the River Musi. It is a small stone of 45 by 80 cm.
The earliest surviving manuscript in Malay is the Tanjong Tanah Law in post-Pallava characters. This 14th-century pre-Islamic legal text produced in the Adityavarman era (1345–1377) of the Dharmasraya Kingdom, a Hindu-Buddhist kingdom that arose after the end of Srivijayan rule in Sumatra. The laws were for the Kerinci people who today still live in the highlands of Sumatra.
From the island of Sumatra, the Malay language spread to peninsular South-east Asia (later known as Malaya and subsequently known as west Malaysia). The Malay language came into widespread use as the trade language of the Sultanate of Malacca (1402–1511). During this period, the Malay language developed rapidly under the influence of Islamic literature. The development changed the nature of the language with massive infusion of Arabic, Tamil, Hindi and Sanskrit vocabularies, called Classical Malay. Under the Sultanate of Malacca the language evolved into a form recognizable to speakers of modern Malay. When the court moved to establish the Riau-Johor Sultanate it continued using the classical language; it has become so associated with Riau and Johor that it is often assumed that the Malay of Riau is close to the classical language. However, there is no connection between Classical Malaccan Malay as used on Riau and the Riau vernacular.
One of the oldest surviving letters written in Malay is letters from Sultan Abu Hayat of Ternate, Maluku Islands in present day Indonesia, dated around 1521–1522. The letter is addressed to the king of Portugal, following contact with Portuguese explorer Francisco Serrão. The letters show sign of non-native usage. This is because the Ternateans were -and still are, using a completely different language as mother tongue: the Ternate language, a West Papuan language. They use Malay only as lingua franca for inter-ethnic communications.