Origin and formation
According to Canggal inscription, this dynasty appears to have been founded in 732 by Sañjaya. The Canggal inscription was discovered in Canggal village, Southwest from the town of Magelang. This inscription was written in south Indian Pallava letters and in Sanskrit, and tells about the erection of a linga (symbol of Shiva) on the hill in Kunjarakunja area. This area is located at a noble island called Yawadwipa (Java) which is blessed with abundance of rice and gold. This inscription tells that Yawadwipa was reigned by King Sanna, whose long period of reign was marked with wisdom and virtue. After king Sanna died, the kingdom fell into disunity. Confusion was widespread due to a lost of ruler and patron. Amidst this, Sanjaya ascended to the throne. He was the son of Sannaha (sister of Sanna). Sanjaya was a king who mastered holy scriptures, martial arts, and also military prowess. He conquered neighboring areas around his kingdom and his wise reign blessed his land with peace and prosperity for all his subjects.
King Sanna and Sanjaya was also known in Carita Parahyangan, a book from later period which mainly tells the history of Pasundan (Sunda Kingdom). This book mentioned that Sanna was defeated by Purbasora, king of Galuh, then he retreated to mount Merapi. Later Sanna's successor, Sanjaya, reclaimed Sanna's kingdom and ruled West Java, Central Java, East Java, and Bali. He was also involved in battle with Malayu and Keling (against their king Sang Srivijaya). The main theme of Carita Parahyangan corresponds to Canggal inscription. This story suggested West Java's origin and links of the dynasty.
Relations with Sailendra
It appears that the Sañjaya dynasty then was forced to the north of Java by the Sailendra dynasty, which emerged around 778. The evidence for this event is based on the Kalasan inscription. During this period, the Sañjaya dynasty existed next to Sailendra dynasty in Central Java, and much of the period was characterized by peaceful co-existence and cooperation.
There are some theories regarding the Sañjaya-Sailendra relationship. Some scholars suggested that there is no such things as Sanjaya dynasty, since there was only one dynasty called Sailendra that ruled central Java. This theory was proposed by Poerbatjaraka and suggested that there was only one kingdom and one dynasty; the kingdom is called Medang with the capital in Mataram area, and the ruling dynasty is Sailendra. He holds that Sanjaya and all of his offsprings were belongs to Sailendra family that initially were Shivaist.
The association of Sailendra with Mahayana Buddhism began after the conversion of Raja Sankhara (Rakai Panaraban or Panangkaran) to buddhism. The later Sailendran kings, successors of Panangkaran become Mahayana Buddhist too and gave Buddhism royal patronage in Java until the end of Samaratungga reign. This theory was based on Raja Sankhara Inscription (now missing), Sojomerto inscription and Carita Parahyangan manuscript. Shivaist Hindu gain royal patronage again since the reign of Pikatan, well until the end of the Medang kingdom.
Another evidence pointed that Sailendra family was using old Malay language in some of their inscriptions, which suggested Sailendra dynasty's foreign origin in Sumatra and their connections with Srivijaya. This theory holds that the Sailendras, with their strong connections to Srivijaya, managed to gain control of Central Java and imposing overlordship on the Rakais (local Javanese lords) including the Sañjaya, thus making the kings of Mataram Sañjaya as their vassals. The center of the dynasty court seems to be located in South Kedu (around Magelang, North of Yogyakarta).
Relations with Champa
Kingdoms of Java maintain a close relationship with Champa kingdom in mainland Southeast Asia since at least the reign of Sañjaya dynasty . Like the Javanese, the Cham are indianized Austronesian people. An example of relationship can be seen in architectural features in Cham temples, that have many similarities with architectural styles of temples in central Java that was built during the reign of Sañjaya dynasty.
The Ruler of Central Java
Rakai Pikatan, who was the crown prince of the Sañjaya Dynasty, wedded Pramodhawardhani (833–856), a daughter of Samaratungga, king of Sailendra. From that time onwards, the influence of Sañjaya, who was a Hindu adherer, began to emerge in Mataram, replacing the Buddhist Sailendra. Rakai Pikatan toppled king Balaputra, son of Samaratungga, also the brother of Pramodhawardhani. As a result in 850, the Sañjaya Dynasty was the sole ruler in Mataram. This ended the Sailendra presence in Central Java and Balaputra retreated to Srivijaya in Sumatra, where he became the paramount ruler.
The information about Sañjaya Dynasty is also found in the Balitung inscription dated 907. According to the Balitung inscription – when a ruler died, they transformed into a divine form. From this inscriptions, the scholars estimated the possible sequence of the ruling kings of Sañjaya dynasty:
- Sanjaya (732—760)
- Panangkaran (760—780)
- Panungalan (780-800)
- Samaragrawira(Rakai Warak) (800—819)
- Rakai Garung (819—838)
- Rakai Pikatan (838—850)
- Rakai Kayuwangi (850—898), also known as Lokapala
- Balitung (898—910)
It was also during the reign of the Sañjaya dynasty, the classic Javanese literature blossomed. The translations and adaptation of classic Hindu literatures into Old Javanese was conducted, such as the Kakawin Ramayana. Around 850s, Pikatan initiated the construction of the Prambanan temple in Central Java, later completed and expanded extensively by king Balitung. Prambanan temple complex is one of the largest Hindu temple in Southeast-Asia and its greatness rivalled Borobudur, which happened to be the biggest Buddhist temple in the world.
The successions of Sañjaya kings after Balitung are:
In 929, Mpu Sindok moved the court of Mataram from Central Java to East Java. It is not entirely clear the actual reasons of the movement. There are some possible reasons; an eruption of Merapi volcano, the power struggle, or probably the Srivijaya empire attacked Mataram. 
- Chihara, Daigorō (1996). Hindu-Buddhist architecture in Southeast Asia. BRILL. ISBN 978-90-04-10512-6.
- Drs. R. Soekmono, (1973, 5th reprint edition in 1988). Pengantar Sejarah Kebudayaan Indonesia 2, 2nd ed. Yogyakarta: Penerbit Kanisius. p. 40. Check date values in:
- Poerbatjaraka, 1958: 254–264
- " De Casparis proposed that in 856 Balaputra was defeated by Pikatan, whereupon Balaputra retreated to Srivijaya, the country of his mother, to become the first Sailendra ruler of Srivijaya. Thus in the late 9th century Srivijaya was ruled by a Buddhist Sailendra ruler, while Java was ruled by Pikatan and his successors who become the patron of Shivaist" (cf. De Casparis, 1956; Hall, 1985:111).
- Coedès, George (1996). The Indianized States of Southeast Asia. University of Hawaii Press. ISBN 978-0-8248-0368-1.