The marriage of Balinese Prince Udayana of the Warmadewa dynasty to east Javanese Princess Mahendradatta in A.D. 989 led to even closer cooperation between Java and Bali. Airlangga (991 - 1046) was born to the royal couple around 1001. As a young man, the prince was sent to Java for his education. There, Airlangga married a princess and became a local shief in a kingdom of his uncle Dharma Wangsa. Shortly after Airlangga's arrival, Wangsa was attacked by the forces of Sriwijaya and murdered. Airlangga ascended to the throne, becoming one of the most glorious monarchs in Java history.
The dynasty he put in place centralized and less Indianized than any up to that time-lasted for more than 300 years. As befits an Indic hero, Airlangga ultimately renounced the kingdom he would made great and died a hermit under the guidance of his spiritual adviser.
A fascinating legend relates how Airlangga's kingdom was nearly destroyed by a plague supposedly brought by the dreadful witch Rangda, queen of evil spirits. According to some historians, Rangda was Airlangga's own mother, Mahendradatta, whom her husband had sent into the jungle for practicing black magic.
Other theorists maintain Rangda sought revenge against Airlangga because he did not side with her when his father took a second wife. Out of the mythical struggle between the magic of the witch and that of the great king arose the legend of Calon Arang, depicted today in Bali's barong dance. Rangda, who died relatively early in life, is thought to be buried in a tomb near Kutri. In Balinese myth she is forever associated with witchcraft.