The mosque was located on a hill known as Ramkot ("Rama's fort"). According to hearsay, Baqi destroyed a pre-existing temple of Rama at the site. Limited historical evidence exists to support this theory and the existence of the temple itself is a matter of controversy. A report by the Archaeological Survey of India suggested that a temple existed at the site. The political, historical and socio-religious debate over the history of the site and whether a previous temple was demolished or modified to create the mosque, is known as the Ayodhya dispute.
Starting in the 19th century, there were several conflicts and court disputes between Hindus and Muslims over the mosque. On 6 December 1992, the demolition of the Babri Masjid by Hindu nationalist groups triggered riots all over India, killing around 2,000 people, many of them Muslim.
The name "Babri Masjid" comes from the name of the Mughal emperor Babur, who is said to have ordered its construction. Before the 1940s, it was called Masjid-i-Janmasthan ("mosque of the birthplace"), including in the official documents such as revenue records.