Somapura Mahavihara in Paharpur, Badalgachhi Upazila, Naogaon District, Bangladesh is among the best known Buddhist viharas in the Indian Subcontinent and is one of the most important archeological sites in the country. It was designated as a UNESCO World Heritage Site in the year of 1985. It dates from a similar time period to the nearby Halud Vihara and to the Sitakot Vihara in Nawabganj Upazila of Dinajpur District.
A number of monasteries grew up during the Pala period in ancient Bengal and Magadha. According to Tibetan sources, five great Mahaviharas stood out: Vikramashila, the premier university of the era, Nalanda, past its prime but still illustrious; Somapura Mahavihara; Odantapurā; and Jaggadala. The monasteries formed a network, "all of them were under state supervision" and there existed "a system of co-ordination among them... it seems from the evidence that the different seats of Buddhist learning that functioned in eastern India under the Pāla were regarded together as forming a network, an interlinked group of institutions," and it was common for great scholars to move easily from position to position among them.
The excavation at Paharpur, and the finding of seals bearing the inscription Shri-Somapure-Shri-Dharmapaladeva-Mahavihariyarya-Bhiksu-Sangghasya, has identified the Somapura Mahavihara as built by the second Pala king Dharmapala (circa 781–821) of Pāla Dynasty. Tibetan sources, including Tibetan translations of Dharmakayavidhi and Madhyamaka Ratnapradipa, Taranatha's history and Pag-Sam-Jon-Zang, mention that Dharmapala's successor Devapala (circa 810–850) built it after his conquest of Varendra. The Paharpur pillar inscription bears the mention of 5th regnal year of Devapala's successor Mahendrapala (circa 850–854) along with the name of Bhiksu Ajayagarbha. Taranatha's Pag Sam Jon Zang records that the monastery was repaired during the reign of Mahipala (circa 995–1043 AD).
The Nalanda inscription of Vipulashrimitra records that the monastery was destroyed by fire, which also killed Vipulashrimitra's ancestor Karunashrimitra, during a conquest by the Vanga army in the 11th century.
Over time Atish's spiritual preceptor, Ratnakara Shanti, served as a sthavira of the vihara, Mahapanditacharya Bodhibhadra served as a resident monk, and other scholars spent part of their lives at the monastery, including Kalamahapada, Viryendra and Karunashrimitra. Many Tibetan monks visited the Somapura between the 9th and 12th centuries.
During the rule of the Sena dynasty, known as Karnatadeshatagata Brahmaksatriya, in the second half of the 12th century the vihara started to decline for the last time.
A copperplate dated to 159 Gupta Era (479 AD) discovered in 1927 in the northeast corner of the monastery, mentions donation of a Brahmin couple to Jain Acharya Guhanandi of Pancha-stupa Nikaya at Vata Gohli, identifiable as the neighboring village of Goalapara.