The area in and around modern Jakarta was part of the fourth century Sundanese kingdom of Tarumanagara, one of the oldest Hindu kingdoms in Indonesia. Following the decline of Tarumanagara, its territories, including the Jakarta area, became part of the Kingdom of Sunda. From 7th to early 13th century port of Sunda is within the sphere of influence of Srivijaya maritime empire. According to the Chinese source, Chu-fan-chi, written circa 1200, Chou Ju-kua reported in the early 13th century Srivijaya still ruled Sumatra, the Malay peninsula, and western Java (Sunda). The source reports the port of Sunda as strategic and thriving, pepper from Sunda being among the best in quality. The people worked in agriculture and their houses were built on wooden piles. The harbour area became known as Sunda Kelapa and by the fourteenth century, it was a major trading port for Sunda kingdom.
The first European fleet, four Portuguese ships from Malacca, arrived in 1513 when the Portuguese were looking for a route for spices. The Kingdom of Sunda made an alliance treaty with Portugal by allowing the Portuguese to build a port in 1522 in order to defend against the rising power of the Sultanate of Demak from central Java. In 1527, Fatahillah, a Javanese general from Demak attacked and conquered Sunda Kelapa, driving out the Portuguese. Sunda Kelapa was renamed Jayakarta, and became a fiefdom of the Sultanate of Banten which became a major Southeast Asia trading center.
Through the relationship with Prince Jayawikarta from the Sultanate of Banten, Dutch ships arrived in Jayakarta in 1596. In 1602, the English East India Company's first voyage, commanded by Sir James Lancaster, arrived in Aceh and sailed on to Banten where they were allowed to build a trading post. This site became the center of English trade in Indonesia until 1682. Jayawikarta is thought to have made trading connections with the English merchants, rivals of the Dutch, by allowing them to build houses directly across from the Dutch buildings in 1615.
The former Stadhuis of Batavia, the seat of Governor General of VOC. The building now serves as Jakarta History Museum, Jakarta Old Town area.
When relations between Prince Jayawikarta and the Dutch deteriorated, Jayawikarta's soldiers attacked the Dutch fortress. Prince Jayakarta's army and the English were defeated by the Dutch, in part owing to the timely arrival of Jan Pieterszoon Coen (J.P. Coen). The Dutch burned the English fort, and forced the English to retreat on their ships. The victory consolidated Dutch power and in 1619 they renamed the city Batavia. Commercial opportunities in the capital of the Dutch colony attracted Indonesian and especially Chinese immigrants. This sudden population increase created burdens on the city. Tensions grew as the colonial government tried to restrict Chinese migration through deportations. On 9 October 1740, 5,000 Chinese were massacred by the Dutch and the following year, Chinese inhabitants were moved to Glodok outside the city walls. The city began to move further south as epidemics in 1835 and 1870 encouraged more people to move far south of the port. The Koningsplein, now Merdeka Square was completed in 1818, the housing park of Menteng was started in 1913, and Kebayoran Baru was the last Dutch-built residential area. By 1930 Batavia had more than 500,000 inhabitants, including 37,067 Europeans. During World War II, the city was renamed from Batavia to "Jakarta" (short form of Jayakarta) by the Indonesian nationalists after conquering the city from the Dutch in 1942 with the help of the Japanese forces.
Following World War II, Indonesian Republicans withdrew from Allied-occupied Jakarta during their fight for Indonesian independence and established their capital in Yogyakarta. In 1950, once independence was secured, Jakarta was once again made the national capital. Indonesia's founding president, Sukarno, envisaged Jakarta as a great international city, and instigated large government-funded projects with openly nationalistic and modernist architecture. Projects included a clover-leaf highway, a major boulevard (Jalan MH Thamrin-Sudirman), monuments such as The National Monument, Hotel Indonesia, a shopping centre, and a new parliament building. In October 1965, Jakarta was the site of an abortive coup attempt in which 6 top generals were killed, precipitating a violent anti-communist purge in which half-a million people were killed, including many ethnic Chinese, and the beginning of Suharto's New Order. A monument stands where the generals' bodies were dumped. In 1966, Jakarta was declared a "special capital city district" (daerah khusus ibukota), thus gaining a status approximately equivalent to that of a state or province. Lieutenant General Ali Sadikin served as Governor from the mid-60's commencement of the "New Order" through to 1977; he rehabilitated roads and bridges, encouraged the arts, built several hospitals, and a large number of new schools. He also cleared out slum dwellers for new development projects—some for the benefit of the Suharto family—and tried to eliminate rickshaws and ban street vendors. He began control of migration to the city in order to stem the overcrowding and poverty. Foreign investment contributed to a real estate boom which changed the face of the city. The boom ended with the 1997/98 East Asian Economic crisis putting Jakarta at the center of violence, protest, and political maneuvering. After 32 years in power, support from President Suharto began to wane. Tensions reached a peak in when four students were shot dead at Trisakti University by security forces; four days of riots and violence ensued that killed an estimated 1,200, and destroyed or damaged 6,000 buildings. Much of the rioting targeted Chinese Indonesians. Suharto resigned as president, and Jakarta has remained the focal point of democratic change in Indonesia. Jemaah Islamiah-connected bombings occurred almost annually in the city between 2000 and 2005, with another bombing in 2009.