Ayilyam Thirunal was born on the 14th of March, 1832 to H.H. Rani Rukmini Bayi, the only sister of Maharajahs Swathi Thirunal and Uthram Thirunal. In the Travancore Royal Family inheritance and primogeniture was determined by the Marumakkathayam system i.e. through the female line. With the accession of Uthram Thirunal in 1846 and his elder brother's exclusion from the line of succession due to imbecility, Ayilyam Thirunal became the Elaya Rajah or heir apparent of Travancore State. Of the seven children born to Rukmini Bayi, only four, including a daughter, Rani Lakshmi Bayi, survived and the eldest and third son were declared unfit to rule owing to mental incapacity. Ayilyam Thirunal's youngest brother Visakham Thirunal was therefore to be his successor.

Ayilyam Thirunal's early education was provided privately and later T. Madhava Rao was appointed tutor to the Elaya Rajah and his brother in 1848. Madhava Rao eventually rose in service and was appointed by Uthram Thirunal in 1857 as Dewan of Travancore and remained in that capacity during the initial decade of Ayilyam Thirunal's reign, until, owing to personal disaffection, he was retired in 1872. In 1854 Ayilyam Thirunal was married to his uncle's daughter, Panapillai Madhavi Pillai Lakshmi Pillai Kochamma of the Thiruvattar Ammaveedu. His consort however died a few years later. In 1860 Maharajah Uthram Thirunal died and Ayilyam Thirunal ascended the musnud as Maharajah.