The temple was originally commissioned by Prince Shōtoku; at the time it was called Wakakusadera, a name that is still sometimes used. This first temple is believed to have been completed by 607. Hōryū-ji was dedicated to Yakushi Nyorai, the Buddha of healing and in honor of the prince's father. Excavations done in 1939 confirmed that Prince Shotoku's palace, the Ikaruga-no-miya (斑鳩宮), occupied the eastern part of the current temple complex, where the Tō-in (東院) sits today. Also discovered were the ruins of a temple complex which was southwest of the prince's palace and not completely within the present temple complex. The original temple, named by modern historians and archaeologists Wakakusa-garan (若草伽藍), was lost, probably burned to the ground after being hit by lightning in 670. The temple was reconstructed but slightly reoriented in a northwest position, which is believed to have been completed by around 711. The temple was repaired and reassembled in the early twelfth century, in 1374, and 1603.
During the Kamakura period, as the cult of Shōtoku rose to prominence in Japan, Horyū-ji became an important site for veneration of the long-dead prince. Ritual practices dedicated to Prince Shōtoku increased in number during this time. A memorial service for the prince called the ceremony of Shōryō-e became an annual event at Hōryū-ji in the early 12th century, and it is still practiced at the temple and other temples associated with Prince Shōtoku to this day. The Kamakura and early Heian period also brought new additions to Hōryū-ji, including the dedication of several new halls in the Eastern and Western compounds to venerate the Prince as the incarnation of the bodhisattva Kannon. The growth of the Shōtoku cult from the 7th century onward propelled the rise of Hōryū-ji as a well-known temple in Japan. By the end of Tokugawa rule in the mid-1800s, the temple was receiving extensive funds from the shogunate on a regular basis. Furthermore, the temple grew and maintained close relations with the Hossō sect throughout the Edo period.
Beginning in the early years of the Meiji period, significant political shifts in Japan brought new challenges for Hōryū-ji. Shinto was instated as the official state religion in 1868, resulting in government confiscation of many Buddhist lands, strict government supervision and categorization of Buddhist temples, and a steep decrease in financial support for Hōryū-ji itself. The recategorization of officially recognized Buddhist sects by the government, which occurred soon after the start of Meiji rule, did not recognize the Hossō sect as a formal institution of Japanese Buddhism. When the seat of the Hossō sect, Kōfuku-ji, was shut down for a time during the Meiji restoration, Hōryū-ji became affiliated with Shingon Buddhism. However, after the government changed its position and allowed Buddhist temples to choose their own affiliated sect in the late 19th century, Hōryū-ji renewed its affiliation with the Hossō school.
Due to the lack of resources during the early Meiji period, the monks at Hōryū-ji decided to donate many of the temple's treasures for museum display. They were able to secure compensation for this donation, improving the financial situation of the temple. Conservation work at the site began in 1895, but culminated in 1934, when a massive restoration project at Hōryū-ji began. The project was interrupted during the Second World War, when large portions of the temple itself were dismantled and hidden in the hills surrounding Nara. However, due to the policy of the United States of America regarding the preservation of cultural sites in Nara and Kyoto, the entire site was spared from bombings during the war. The restoration project resumed after the war and concluded in 1985. Much of the temple complex was repaired from centuries of environmental damage. During the restoration, older paintings of the temple were used to determine the original layout of the complex, and many of the living quarters built during the intervening years were demolished.
Today, the temple can be identified as the headquarters of the "Shōtoku" sect, and is a popular site for pilgrimage. As a UNESCO World Heritage Site, Hōryū-ji is also an attractive site for tourists. According to the temple's website, it is currently home to over 180 of Japan's designated National Treasures and Important Cultural Properties, and was the first structure in Japan to become a World Heritage Site. Hōryū-ji also still holds frequent events in a variety of locations in the complex, and many of its structures are open to the public.