King Sanjaya of Mataram or in complete stylized name known as Rakai Mataram Sang Ratu Sanjaya was the founder of Mataram Kingdom during the eighth century. His name was revealed in the AD 732SanskritCanggal inscription carved in a stone found at Gunung Wukir temple that stood on Wukir or Ukir hill on the southern Kedu Plain in Central Java. Another recorded source of Sanjaya's history and his successors is found in the Balitung charter and the Wanua Tengah III inscription. In the Mantyasih inscription, Balitung mentions what are called 'the builders of keraton', starting from Rakai Mataram followed by the Maharaja Rakai Panangkaran, Panunggalan, Warak, Garung, Rakai Pikatan, Kayuwangi, Watuhumalang and Watukura.. Several inscriptions of Balitung's successor, Daksha, use a dating system based on the year of Sanjaya's accession, which L.C. Damais has calculated as 638 Śaka. Sanjaya was also known as Rakai Mataram with the additional title of 'Sang Ratu Sanjaya'. The title rakai indicates any members of nobility from a king to a simple squire. The name of King Sanjaya Saga was also mentioned in the old romanticized and mythicized Sundanese manuscript of Carita Parahyangan dated from later period, in which Sanjaya was portrayed as the Sundanese king hero of Galuh.
Bosch suggested that Sanjaya was the progenitor of the Sanjaya Dynasty, and there were two dynasties that ruled Central Java; the Buddhist Sailendra and the ShivaistSanjaya dynasty. The inscription also states that Sanjaya was an ardent follower of Shaivism. The latter was forced to move eastward by Sanjaya as written in an old Chinese report, which named Sanjaya as Chi-Yen. Yet other historians argued that there was no such thing as Sanjaya dynasty, since there was only one dynasty mentioned in inscriptions 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. The association of Sailendra with Mahayana Buddhism began after the conversion of Raja Sankhara to Buddhism.
In the Canggal inscription
According to Canggal inscription, Sanjaya commissioned the erection of a lingam on the hill of Kunjarakunja. The lingam is sited on the noble island of Yawadwipa, which the inscription describes as blessed with an abundance of rice and gold. Yawadwipa, the inscription says, had long been under the rule of the wise and virtuous king Sanna, but fell after his death into disunity. Amid a period of confusion Sanjaya, son of Princess Sannaha ascended to the throne. Sanjaya mastered holy scriptures, martial arts, and displayed military prowess. After the conquest of neighboring areas his reign was peaceful and prosperous. This inscription describes Sanjaya as the legitimate successor of previous king of Java, Sanna. After Sanna's kingdom fell into disunity, Sanjaya reunite the kingdom and ascends to the throne. By erecting a Shivaic linggam he demonstrate the establishment of new authority, a new center of political power or court. Sanjaya accession to his throne was proclaimed in the Ukir inscription. An analysis to the inscription, which marked as a warning to vassal states and defeated kings, suggests that the Ukir hill was the first center of Mataram Kingdom. Sanjaya or his successor Panamkarana later moved the kraton between AD 742—755, as written in a Chinese annal.
In the Carita Parahyangan
According to the Carita Parahyangan, Sanjaya was instead the son of King Sanna of Galuh and Princess Sannaha. King Sanna was defeated by his cousin, Purbasora. As a result, Sanna had to retreat to Kalingga, the kingdom of his wife's grandmother. To avenge the defeat of his father, Sanjaya started to organise a special force. Meanwhile, Tarusbawa, King of Sunda and a good friend of King Sanna, accepted Sanjaya as his son-in-law. So, Sanjaya's special force, combined with the Sunda army, attacked Purbasora's kingdom and killed him along with his family. Thereafter, Sanjaya claimed the kingdoms of Sunda, Galuh and Kalingga and established the Medang Kingdom or Mataram Kingdom. Thus, with his coronation, East Java, West Java, Central Java and Bali were united under one rule.