Kotagede (also Kota Gede, Javanese for "Big City") is a historic neighborhood in Yogyakarta, Indonesia. The name was also used for the administrative district (kecamatan) of the same name in the City of Yogyakarta. Kotagede contains the remains of the first capital of Mataram Sultanate, established in the 16th century. Some of the remains of the old Kotagede are remains of the palace, the royal cemetery, the royal mosque, and defensive walls and moats. Kotagede is well known internationally by its silver crafting.
Kotagede was previously a forest named Mentaok, to the east of Gajah Wong River. During the last quarter of the 16th century, the ruler of the Islamic Kingdom of Pajang, about 100 kilometers to the east of this site, awarded the forest to Ki Ageng Pemanahan, one of his courtiers who successfully put down a rebellion. Pemanahan opened the forest with his son Danang Sutawijaya, who was also an adoptive son of the ruler. A settlement was established and was named Mataram as Pemanahan himself was called Ki Gedhe Mataram, "the Lord of Mataram".
After Pemanahan's death in 1575, Danang Sutawijaya announced himself king of Mataram with the title of Panembahan Senapati Ingalaga, "the Lord to Whom Obeisance is Paid, Commander in the Battlefield." He expanded his territory by conquering some major parts of Java, including Pajang, the capital of his adoptive father. The small town became the capital of Mataram and perhaps since then it was dubbed Kotagede, "Great City". During this time the town was fortified with walls. The western wall was built along Gajah Wong River, channeled to water the moats on three other sides of the fort.
To successfully govern a territory, Senapati also established alliance with supernatural power by performing austere meditation. According to Babad Mangkubumi, while performing a meditation on a stone in the middle of a river in between mount Merapi and the Indian Ocean, a gigantic mythical fish named Tunggulwulung offered Senapati a ride to venture south of the ocean where the most powerful spirit of Java governed the netherworld, named Kangjeng Ratu Kidul. Overwhelmed by the aura of Senapati, the queen offered support for his great efforts to conquer the people of Java. She even presented herself to be his consort, as well as to all his reigning descendants, up to present.