The gamelan has an old and mysterious origin. Apparently it predates the Hindu-Buddhist culture that dominated Indonesia in its earliest records, and instead represents a native art form. The instruments developed into their current form during the Majapahit Empire. In contrast to the heavy Indian influence in other art forms, the only obvious Indian influence in gamelan music is in the Javanese style of singing.
In Javanese mythology, the gamelan was created by Sang Hyang Guru in Saka era 167 (c. AD 230), the god who ruled as king of all Java from a palace on the Maendra mountains in Medangkamulan (now Mount Lawu). He needed a signal to summon the gods, and thus invented the gong. For more complex messages, he invented two other gongs, thus forming the original gamelan set.
In the palaces of Java are the oldest known ensembles, the Munggang and Kodokngorek gamelans, apparently from the 12th century. These formed the basis of a "loud style." A different, "soft style" developed out of the kemanak tradition and is related to the traditions of singing Javanese poetry, in a manner which is often believed to be similar to performance of modern bedhaya dance. In the 17th century, these loud and soft styles mixed, and to a large extent the variety of modern gamelan styles of Bali, Java, and Sunda resulted from different ways of mixing these elements. Thus, despite the seeming diversity of styles, many of the same theoretical concepts, instruments, and techniques are shared between the styles.