The kraton (palace) of Yogyakarta is surrounded by two defensive walls. The Cepuri is the inner wall and the Baluwarti the outer wall. The construction in 1785 of the Baluwarti (the name derives from the Portuguese word ‘baluarte’ meaning bulwark) was an initiative of crown prince Adipati Anom, the crown prince of sultan Hamengkubuwono I. The construction of the outer defensive wall was a reaction to the building of the Dutch fort Vredeburg north of the kraton.
The baluwarti is circa five kilometers long and has a bastion at each of the four corners. The wall of red brick is two to six meters thick and four to six meters high. On the top of the wall is a passage that connects the four bastions on the rampart. The baluwarti was surrounded by a moat. The construction of the wall was marked by a symbolic ornament in the form of 'suryasengkala' the 'Paninggaling Kawicakranan Salingga Bathara' which means the year 1785. There were five entrance gates with draw bridges over the moat: Tarunasura or Wijilan gate on the northeast side, Jagasura or Ngasem gate on the northwestern side, the Jagabaya or Tamansari gate on the west side, and Madyasura, Tambakbaya or Gondomanan gate in the east and Nirboyo or Gadhing gate on the south side.
In November 1809, Adipati Anom was crowned and given the title 'Sri Sultan Hamengkubuwono II'. Adipati Anom then fortified the fort further by enlarging its bastions by 5 to 6 meters, as a precaution against possible attacks from Dutch army under Governor General Herman Willem Daendels (1808-1811). In 1810 the Governor General came to Yogyakarta, deposed the sultan, and installed his son, Hamengkubuwono III.
In 1811 the British occupied Java. Hamengkubuwono II was reinstated as king and his son reverted back to crown prince. The relations between the king and Lieutenant Governor James Stamford Raffles were as bad as his relation with the Dutch. On June 17, 1812 Raffles came to Yogyakarta with an army. Negotiations had no success. After the outbreak of the hostilities the artillery of fort Vredeburg fought a duel with the canons in the kraton. The powder house in the northeast bastion of the Bulwarti exploded. On 20 June British troops stormed the breach in the wall and the north gate and occupied the kraton.
Hamengkubuwono II was exiled to Penang and his son became sultan.
Today a part of the southern wall and three of the four bastions of Baluwarti remain. The demolished north east bastion was never rebuilt. The streets along the east, north, west and part of the south sides became a residential area. Most houses are attached to the fortification wall.