Sanjaya dynasty

Sanjaya dynasty was an ancient Javanese dynasty that ruled the Mataram kingdom in Java during first millennium CE. The dynasty was an active promoter of Hinduism in ancient Java.
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 TamilPallava letters 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 loss of a ruler and patron. Amidst this, Sanjaya ascended to the throne. According to this inscription, he was the son of Sannaha, who is described as the sister of King 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.
According to Carita Parahyangan (a book from later period which mainly tells the history of Sunda Kingdom), Sanjaya was instead the son of King Sanna and Sannaha. This relationship of King Sanna and Sanjaya was not provided in the Canggal inscription. It also mentions that King Sanna was defeated by his cousin, King Purbasora of Galuh, and so, he had to retreat to Mount Merapi. Later, 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). 
Apart from minor differences, the main theme of Carita Parahyangan corresponds to Canggal inscription. This story suggested the links of the dynasty with West Java.
Relations with Sailendra.
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 offspring were belongs to Sailendra family that initially were Shivaist.
Another suggests 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.
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 incorporated the kings of Mataram Sañjaya dynasty in their bureaucracy. 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:
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:
Decline.
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 political pressure from Sailendran based in Srivijaya Empire may have caused the move.
The shift to East Java marked the end for the Central Javanese Sañjaya dynasty, and from then on a new dynasty named the Isyana Dynasty emerged in East Java.