The city was earlier known as Prayāga, a name still commonly used. Prayāga existed during the Vedic period, and is mentioned in the Veda as the location where Brahma (the Hindu creator of the universe) attended a ritual sacrifice. Excavations have revealed Northern Black Polished Ware dating to 600–700 BCE. The Puranas record that Yayati left Prayaga and conquered the region of Saptha Sindhu. His five sons (Yadu, Druhyu, Puru, Anu and Turvashu) founded the main tribes of the Rigveda. Lord Rama, the protagonist of the Ramayana, spent time at the Ashram of Sage Bharadwaj before travelling to nearby Chitrakoot.

When the Aryans first settled in what they called the Āryāvarta (or Madhyadesha), Allahabad (then Kaushambi) was an important part of their territory. The Kurus, rulers of Hastinapur (near present-day Delhi), established the town of Kaushambi near Allahabad. They shifted their capital to Kaushambi when Hastinapur was destroyed by floods.

The Doab region, which includes Allahabad, was controlled by a succession of empires and dynasties. The area became part of the Maurya and Gupta Empires from the east and the Kushan Empire from the west before being governed by Kannauj during the 15th century.[19] The city was the site of Maratha incursions before India was colonised. Allahabad became a part of the Delhi Sultanate when it was annexed by Mohammad Ghori in 1193. Later, the Mughals took over from the slave rulers of Delhi and under them Allahabad rose to prominence. Allahabad was a provincial capital in the Moghul Empire under the reign of Jahangir. Padshah (emperor) Akbar the Great made it the seat of Illahabad Subah, one of his twelve original subahs (imperial top-level provinces), built a fort on the banks of the sangam and renamed the settlement Ilāhābād (Persian for “place of a god”) in 1575. A unique artefact associated with Jahangir’s reign found in Allahabad is a large jade terrapin, now in the British Museum’s collection.

In 1765, forces of Mir Qasim, the Nawab of Bengal, Shuja-ud-Daula, the Nawab of Awadh and the Mughal emperor Shah Alam II lost the Battle of Buxar to the British; this was followed by the Treaty of Allahabad. Although the British did not yet establish direct rule, they saw Allahabad’s strategic position and in 1765 established a garrison in Akbar’s Allahabad Fort. In 1801, the Nawab of Awadh ceded the city to the British East India Company. Gradually, the rest of the Doab and its adjoining western region in its west (including Delhi and Ajmer-Merwara) came under British rule. The northwestern area became a new presidency, the North Western Provinces of Agra, with its capital at Agra. Allahabad was an important part of the state. In 1834, the city became the governmental seat of Agra Province and a High Court was established; a year later, both were moved to Agra. Allahabad was a participant in the 1857 Indian Mutiny, when Maulvi Liaquat Ali unfurled the banner of revolt. During the rebellion Allahabad, with a number of European troops, was the scene of a massacre.

After the mutiny, the British established a high court, a police headquarters and a public-service commission in Allahabad, making the city an administrative centre. They truncated the Delhi region of the state, merging it with the Punjab and moving the capital of the North-Western Provinces to Allahabad (where it remained for 20 years). In January 1858, Earl Canning departed Calcutta for Allahabad. That year he read Queen Victoria’s proclamation, transferring control of India from the East India Company to the British Crown (beginning the British Raj), in Minto Park. In 1877 the provinces of Agra and Awadh were merged to form the United Provinces, with Allahabad its capital until 1920.

The 1888 session of the Indian National Congress was held in the city, and by the turn of the 20th century Allahabad was a revolutionary centre. Nityanand Chatterji became a household name when he hurled a bomb at a European club. In Alfred Park in 1931, Chandrashekhar Azad died when surrounded by British police. The Nehru family homes, Anand Bhavan and Swaraj Bhavan, were centres of Indian National Congress activity. During the years before independence Allahabad was home to thousands of satyagrahis led by Purushottam Das Tandon, Bishambhar Nath Pande, Narayan Dutt Tiwari and others. The first seeds of the Pakistani nation were sown in Allahabad. On 29 December 1930, Allama Muhammad Iqbal’s presidential address to the All-India Muslim League proposed a separate Muslim state for the Muslim-majority regions of India.

Allahabad is known as the “city of prime ministers” because seven out of 15 prime ministers of India since independence have connections to Allahabad (Jawaharlal Nehru, Lal Bahadur Shastri, Indira Gandhi, Rajiv Gandhi, Gulzarilal Nanda, Vishwanath Pratap Singh and Chandra Shekhar). All seven leaders were either born there, were alumni of Allahabad University or were elected from an Allahabad constituency.