Madurai has been inhabited since at least the 3rd century BCE. Megasthenes may have visited Madurai during the 3rd century BCE, with the city referred as "Methora" in his accounts. The view is contested by some scholars who believe "Methora" refers to the north Indian city of Mathura, as it was a large and established city in the Mauryan Empire. Madurai is also mentioned in Kautilya's Arthashastra. Sangam literature like Maturaikkāñci records the importance of Madurai as a capital city of the Pandyan dynasty. Madurai is mentioned in the works of Roman historiansPliny the Younger, Ptolemy, those of the Greek geographer Strabo, and also in Periplus of the Erythraean Sea. , first ruler of the Sultanate of Madurai, 1335–1339 CE After the Sangam age, most of present-day Tamil Nadu, including Madurai, came under the rule of the Kalabhra dynasty, which was ousted by the Pandyas around 590 CE. The Pandyas were outsted from Madurai by the Chola dynasty during the early 9th century. The city remained under the control of the Cholas until the early 13th century, when the second Pandyan empire was established with Madurai as its capital.
In 1801, Madurai came under the direct control of the British East India Company and was annexed to the Madras Presidency. The British government made donations to the Meenakshi temple and participated in the Hindu festivals during the early part of their rule. The city evolved as a political and industrial complex through the 19th and 20th centuries to become a district headquarters of a larger Madurai district. In 1837, the fortifications around the temple were demolished by the British. The moat was drained and the debris was used to construct new streets – Veli, Marat and Perumaal Mesthiri streets. The city was constituted as a municipality in 1866 CE. The British government faced initial hiccups during the earlier period of the establishment of municipality in land ceiling and tax collection in Madurai and Dindigul districts under the direct administration of the officers of the government. The city, along with the district, was resurveyed between 1880 and 1885 CE and subsequently, five municipalities were constituted in the two districts and six taluk boards were set up for local administration. Police stations were established in Madurai city, housing the headquarters of the District Superintendent. Under the British Madurai prospered. It was in Madurai, in 1921, that Mahatma Gandhi, pre-eminent leader of Indian nationalism in British-ruled India, first adopted the loin cloth as his mode of dress after seeing agricultural labourers wearing it. Leaders of the independence movement in Madurai included N.M.R. Subbaraman, Karumuttu Thiagarajan Chettiar and Mohammad Ismail Sahib. The Temple Entry Authorization and Indemnity Act passed by the government of Madras Presidency under C. Rajagopalachari in 1939 removed restrictions prohibiting Shanars and Dalits from entering Hindu temples. The temple entry movement was first led in Madurai Meenakshi temple by independence activist A. Vaidyanatha Iyer in 1939.