The Allahabad Fort was constructed by the Mughal Emperor Akbar in 1583. Abu'l-Fazl, in his Akbarnama writes: Akbar named the fort Illahabas, which later became "Allahabad". Besides the strategic location of Allahabad, Akbar is also thought to have been motivated by the ability to collect taxes from the large number of pilgrims visiting the Triveni Sangam. However, this seems unlikely, considering the fact that Akbar abolished the existing pilgrim taxes in 1563. Akbar's fort was constructed in such a way that it enclosed the famous Akshayavat tree, where people would commit suicide in order to achieve salvation. The reason for this is not known, although some sources claim that he did it to prevent people from committing suicides. According to a local legend, Akbar was a Hindu ascetic named Mukunda Brahmachari in his previous birth. Once, by mistake, he consumed a cow's hair while drinking milk. Horrified at this sin, he committed suicide. He was born a mlechchha as a result of this sin, and was driven to build a fort at the holy Sangam. The local Prayagwal Brahmins claim that Akbar repeatedly failed to construct the fort, because its foundation would sink in the sand each time. The emperor was told that a human sacrifice was required to proceed. A local Brahmin voluntarily sacrificed himself, and in return, Akbar granted his descendants — the Prayagwals — the exclusive rights of servicing the pilgrims at the Sangam. The Allahabad Fort is the largest fort built by Akbar. This fort has three galleries flanked by high towers.
The fort was first garrisoned by British East India Company troops in 1765 as part of the Treaty of Allahabad, signed after the Battle of Buxar by Commander-in-Chief of British IndiaRobert Clive, Mughal Emperor Shah Alam II, and the ruler of Awadh, Nawab Shuja-ud-Daula. According to this treaty, the British garrison in the fort was to defend and protect Shah Alam, however, Shah Alam, finding this arrangement restrictive, slipped away to Delhi in 1772, where he attempted to cede Allahabad to the Maratha Empire. The British intervened and contrived to nullify Alam's claim to the fort, proclaiming Shuja-ud-Daula its sole owner. Shuja-ud-Daula died and was succeeded as Nawab of Awad by Asaf-ud-Daula in 1775; despite persistent attempts of the Company to formally acquire the fort, it remained in the Nawab's hands. Asaf-ud-Daula died in 1787, leaving large debts to the Company and an heir of disputed parentage, who was promptly deposed by Saadat Ali Khan I. Finally, in February 1798, a financially strapped Saadat Ali ceded the fort to the Company. Three years later, in 1801, Saadat Ali finally ceded the district of Allahabad to the British. Once Allahabad became a functional part of the East India Company's territories, its fort was established as the grand depot for military stores.