It was built by the Mughal Emperor Shah Jahan between 1650 and 1656 at a cost of one million rupees, and was inaugurated by Imam Syed Abdul Ghafoor Shah Bukhari from Bukhara. The mosque was completed in 1656 AD with three great gates and two 40 metres high minarets constructed with strips of red sandstone and white marble. The courtyard can accommodate more than 25000 people. There are three domes on the terrace which are surrounded by the two minarets. On the floor, a total of 899 black borders are marked for worshippers. The architectural plan of Badshahi Masjid, built by Shah Jahan's son Aurangzeb at Lahore is similar to the Jama Masjid.