People were living and writing here long before any Europeans arrived. Near Tanjung Priok, the Tugu inscription from the 5th century records two waterways dug under a king named Purnawarman. By the early 1500s the harbour of Kalapa was the Sunda Kingdom's most important trading port, taking ships from Sumatra, Malacca and Java. That harbour is Sunda Kelapa. Traditional inter-island boats still tie up there today.
In 1522 the Sunda king let the Portuguese build a fort at Kalapa, hoping for help against the Muslim sultanates of Cirebon and Demak. It didn't save him. In 1527 Islamic forces took the port, led by Fatahillah or by Sunan Gunung Jati, depending on the source, and it fell under the Sultanate of Banten. The town became Jayakarta, a Sanskrit name meaning victory, and that name lives on in today's Jakarta.
The Dutch and English East India Companies both wanted the port. In May 1619 Jan Pieterszoon Coen of the Dutch VOC stormed Jayakarta and burned its royal residence. The company built its Asian headquarters on the site and named it Batavia, after a Germanic tribe the Dutch claimed as ancestors. It was laid out as a walled town of canals at the mouth of the Ciliwung, a copy of home in a tropical swamp. The canals silted up, disease spread from the 1730s, and Batavia earned the name White Man's Graveyard.
Chinese residents worked in Batavia's trade, farming, crafts and construction. Then in 1740 trouble with Chinese labourers in the lands around the city ended in a massacre of the city's Chinese, with tens of thousands killed. The following year the VOC designated a Chinese quarter south of the old town. That quarter is Glodok, still Jakarta's Chinatown.
By the early 1800s the well-off were giving up on the old town and moving inland to Weltevreden, today's Central Jakarta, a district of government buildings and big houses with gardens. The British held the city from 1811 to 1816, with Stamford Raffles in charge, before handing it back. The city kept spreading south, and Menteng, laid out in the 1910s, became a residential district for the middle class, planned to be healthy. Its early houses have broad eaves and Art Deco touches. In March 1942 Japan took Batavia and renamed it Jakarta.
On 17 August 1945, Indonesia declared independence here. During the war with the Dutch that followed, the Republic ran itself from Yogyakarta, and Jakarta only became the capital again in 1950. Sukarno, an architect by training, then set out to make it a showpiece for a new nation. Around the 1962 Asian Games he pushed through Monas, Hotel Indonesia, the Sarinah department store, the Senayan sports complex and the wide Thamrin and Sudirman avenues. Building was so intense that ordinary residents struggled to buy cement. Most of the city's monuments were begun in that first half of the 1960s.
After the violence of 1965 and 1966, Suharto took power. A kampung improvement programme brought basic services to crowded neighbourhoods, though modernising also displaced some poor ones. High-rise building along Thamrin and Sudirman then accelerated. The 1997 financial crisis brought students onto the streets, and Suharto resigned on 21 May 1998. In 2022 the government began moving the capital to Nusantara, a new city in East Kalimantan. Jakarta stays the capital until a presidential decree makes the move official, and it will remain the country's business centre either way.