Shah Jahan built it as the imperial mosque of his new capital, Shahjahanabad, and Syed Abdul Ghafoor Shah Bukhari, invited from Bukhara to serve as its first imam, opened it on 23 July 1656. The emperor named it Masjid-i-Jehan-Numa, the "mosque that reflects the whole world"; the common name, Jama Masjid, simply means congregational mosque. It remains Delhi's main mosque, where the city's Muslims gather for weekly congregational prayers and for Eid.

Around 5,000 workers built it, among them Indians, Arabs, Persians, Turks and Europeans, under the supervision of the wazir Sadullah Khan and Fazil Khan. Shah Jahan said he had modelled it on the Jama Masjid at Fatehpur Sikri, which shows in the façade and courtyard, while the interior is closer to the Jama Masjid in Agra. The Mughal emperors read the khutba, the weekly sermon, here as a sign of their authority. After the revolt of 1857, the British seized the mosque, used it as barracks and returned it to Delhi's Muslims only in 1862. On 23 October 1947, during Partition, the independence leader Abul Kalam Azad spoke from its pulpit urging the city's Muslims to stay in India; his tomb lies beside the mosque.

Three sandstone gates, each reached by a broad stairway, lead in. The three-storey eastern gate was the royal entrance reserved for the emperor, while the two-storey northern and southern gates served everyone else. A cabinet in the north gate holds relics associated with the Prophet Muhammad, among them a Quran written on deerskin, a hair from his beard, his sandals and a footprint set in marble.

The square courtyard, paved in red sandstone and at least 99 metres on each side, can hold 25,000 worshippers, with a marble ablution tank in the middle and domed pavilions rising at its four corners above open arcades. On its west side, the prayer hall opens through a tall central arch flanked by five smaller cusped arches on each side, with calligraphy above them. Inside, seven prayer niches line the qibla wall, the central one clad in marble beside a marble pulpit, and the floor is inlaid with white and black marble to look like rows of prayer mats. The two minarets, 41 metres high and striped lengthwise with white marble, each have 130 steps and three viewing galleries, and end in a small marble pavilion.

Shah Jahan gave the mosque's imam the title of Shahi Imam, the royal imam, and the office has passed down among descendants of the first imam, who bear the family name Bukhari after their origins in Bukhara. Every Mughal emperor from Aurangzeb onwards, down to Bahadur Shah II, was crowned by the Shahi Imam of this mosque.