The Masjid-i Jami of Herat, the city's first congregational mosque, was built on the site of two smaller Ghaznavid mosques that were destroyed by earthquake and fire. The present mosque was begun by Ghurid ruler Ghiyath al-Din Muhammad b. Sam (1162-1202) in 1200 (597 AH), and continued after his death by his brother and successor Shihab al-Din. This is confirmed both by an inscription on the eastern Ghurid portal uncovered in 1964 during a restoration, and by the sixteenth century Timurid historian Khwandamir in his Khulasat al-Akhbar. It is debated whether this mosque was originally sited at the city center, although it was probably built in the northwest quarter of the medieval city, within the original walls. According to Lisa Golombek, Ghiyath al-Din Muhammad respected the original westerly orientation that reflected its Hanafite tradition, although his Shafi'ite tradition would have favored a southern orientation of the qibla.
In the thirteenth century, Chingiz Khan pillaged the province and the building fell into ruin. Rebuilding and renovation programs were undertaken by the Kart rulers in 1306 (706 AH) and again after a devastating earthquake in 1364. After 1397, the Timurid rulers redirected Herat's growth towards the North. This suburbanization and the building of a new Friday mosque in Gawhar Shad's Musalla marked the end of the Masjid-i Jami's patronage by a monarchy. Repairs between 1404 and 1446 (807 – 850 AH) were completed by Jalal al-Din Firuzshah, one of the most prominent amirs of Shah Rukh bin Timur (1405-1444). According to Richard N. Frye, the mosque was then rebuilt by Mir Ali Shir Navai — a prominent poet and minister of Sultan Husain Baiqara (1469-1506) — in two years beginning in 1498 (903 AH), although Isfizari states that the decorations alone were completed over the course of five years. By the mid-twentieth century, little remained of the Timurid mosque, at which time, the structure was reconstructed and extended as part of a larger urban project.
The plan for the new mosque corrects the irregularities of the original mosque layout and reconstructs elements (like the mausoleum), which were entirely lost by the 1940s. The new mosque is rectangular with four deeply vaulted iwans and domed hypostyle halls around a courtyard, with a reconstruction of the mausoleum of Ghiyath al-Din Muhammad bin Sam located behind the northern iwan. The main portal faces east. There are five secondary entrances along the north and east walls, including the last remaining Ghurid portal at the southeastern corner of the mosque complex. The exterior and courtyard walls are all richly decorated with pink bricks covered with plaster and predominantly blue tilework with vegetal and floral motifs. The exterior was entirely and heavily restored prior to 1970.
The eastern façade of the Masjid-i Jami is contemporary. The symmetrically arranged entry elevation has a pishtaq flanked on either side by bi-level arched niches, minarets, and long walls with blind arches. The pishtaq and the arched niches have complex ribbed vaults. To the left of the entrance is the original completion plaque composed in Kufic style that announces the date of construction and gives praise to the donor. At the southernmost edge of this façade, behind the screen wall, is a portal from the Ghurid mosque. Its double-arched niche is crowned with a brick squinch-net vault. It has been lightly restored. The doorway is flanked with two engaged columns. The surfaces of the columns and the spandrels of the portal arch are covered with geometric carvings in pink stone. On either side of the doorway are panels of kufic inscriptions carved in stone and highlighted with blue tiles.
The eastern portal iwan is comprised of a half-dome chamber and muqarnas vaulting. This portal leads to the courtyard through a series of three small vestibules. The mosque courtyard is an expansive paved surface, measuring approximately 121 meters by 174 meters; it is lined with single storey arcades with four centered iwans. These iwans are not domed, but instead have deeply recessed arches. In the southeast corner of the courtyard is the Kartid period cauldron, which was made in 1375 and is still used for distributing fruit-flavored syrup (sharbat). There is a small standing mihrab (namazgah) in the courtyard.
The sanctuary iwan to the west is the largest and deepest. The eastern portal iwan is next in size, and the two lateral iwans are smallest. The two minarets at the corners of the sanctuary pishtaq underline the significance of this mass, which contains a mihrab niche on its western wall. Surrounding the courtyard on all four sides are domed or vaulted hypostyle prayer halls. The halls are seven bays deep on the west, eight bays deep on the east and five bays deep on the north and south sides of the courtyard. Accessed through the courtyard arcade, the bays are enclosed in certain sections to create rooms or corridors. Typical of monuments in Herat, where timber and stone were unavailable, the mosque was built of mud-bricks covered in plaster.
Originally a large square structure, the tomb of Ghiyath al-Din Muhammad bin Sam to the north of the courtyard was rebuilt as an octagonal hall with circular niches on the interior walls. It is entered through a three-sided projection on the northern mosque wall, which is carved with three deep niches and crowned with two minarets.
Overall, the mosque's multiple reconstructions and restoration programs leave little to authenticate as original. Twentieth century programs, most notably the 1945 program mentioned by Richard Frye, have expanded the northeastern section of the mosque from a length of approximately 101 meters to 121 meters. The exterior was redecorated with tiles and carved stone, and sections of the courtyard arcade were glazed. The reflecting pool at the center of the courtyard and the single tree at its northwest corner were also removed during these restorations.