Gelgel is a village (desa) that is situated in the regency (kabupaten) of Klungkung, on the Island of Bali, Indonesia. The village, which lies four kilometers south of the regency capital Semarapura, not far from the coast, contains a number of culturally interesting structures. It is known for its pottery and handwoven ceremonial songket cloth. The village mainly owes its fame to the kingdom of Gelgel, which dominated Bali from perhaps the early 16th century to 1686. There are no traces left today of the old royal palace (puri). The old ancestral shrine of the ruling dynasti, Pura Jero Agung, is still standing in the old palace area. To the east of Pura Jero Agung is another old temple, Pura Dasar, which is a lowland counterpart of the "mother temple" of Bali, Pura Besakih. The village also contains the oldest mosque of Bali, which was built by Javanese retainers of the old kings.
The history of Gelgel is described in some detail in the traditional chronicles (babad), in particular the 18th-century work Babad Dalem. According to these texts, the conquest of Bali by the Hindu Javanese kingdom of Majapahit was followed by the installation of a vassal dynasty in Samprangan in the present-day regency Gianyar, close to the old royal centre Bedulu. This installation took place in the age of the outstanding Majapahit minister Gajah Mada (d. 1364). The first Samprangan ruler Sri Aji Kresna Kepakisan sired three sons. Of these the eldest, Dalem Samprangan, succeeded to the rulership but turned out to be a vain and incompetent ruler. His youngest brother Dalem Ketut founded a new royal seat in Gelgel while Samprangan lapsed in obscurity. He later visited Majapahit and received powerful heirlooms (pusaka) from the king Hayam Wuruk. After a while the Majapahit kingdom fell into chaos and vanished, which left Dalem Ketut and his Balinese kingdom as the heirs of its Hindu-Javanese culture. This traditional account is problematic since it includes irreconcilable chronological difficulties; the Majapahit ruler Hayam Wuruk died in 1389, while the fall of Majapahit occurred much later, in the early 16th century.