The early history of Indonesia is the story of dozens of kingdoms and civilizations flourishing and fading in different parts of the archipelago. Some notable kingdoms include Srivijaya (7th-14th century) on Sumatra and Majapahit (1293-c.1500), based in eastern Java but the first to unite the main islands of Sumatra, Java, Bali and Borneo (now Kalimantan) as well as parts of the Malay Peninsula.
The first Europeans to arrive (after Marco Polo who passed through in the late 1200s) were the Portuguese, who were given permission to erect a godown near present-day Jakarta in 1522. By the end of the century, however, the Dutch had pretty much taken over and the razing of a competing English fort in 1619 secured their hold on Java, leading to 350 years of colonization.
Various nationalist groups developed in the early 20th century, and there were several disturbances, quickly put down by the Dutch. Leaders were arrested and exiled. Then during World War II, the Japanese conquered most of the islands. After the war, Indonesia's founding fathers Sukarno (Soekarno) and Hatta declared the independence of the Republic of Indonesia. After four years of fighting, the Dutch accepted this on December 27, 1949. The 1950 constitution was an attempt to set up a liberal democracy system with 2 chambers of parliament. Indonesia held its first free election in 1955.
In 1959, Sukarno dissolved the cabinet and parliament, appointed himself PM, and created a new parliament. He called his autocratic rule "Guided Democracy". Much to the dismay of the West, Sukarno aligned himself somewhat with Moscow and had the Communist party's Dr Subandrio as Deputy PM and intelligence chief. The government had various troubles including a communist coup attempt and an anti-communist CIA-backed rebellion in West Sumatra and North Sulawesi, complete with the 7th Fleet offshore.
In 1965, things came to a head. Dr Subandrio produced a document, allegedly stolen from the British Embassy, detailing plans for a military coup. The presidential guard killed some of the officers involved, then guard colonel Untung announced that he, Subandrio and various other leftist Indonesian leaders had formed a "Revolutionary Council" to take over the power. Army units under General Suharto put down the rebellion in a single day. Suharto then seized power himself, sidelining Sukarno, proclaiming a New Order (Orde Baru) and initiating a series of bloody anti-Communist purges that led to the death of 500,000-2,000,000 people (estimates vary widely).
Under Suharto from 1966 to 1997, Indonesia enjoyed stability and economic growth, but most of the wealth was concentrated in the hands of a small corrupt elite and dissent was brutally crushed. During the Asian economic crisis of 1997 the value of the Indonesian rupiah plummeted, halving the purchasing power of ordinary Indonesians, and in the ensuing violent upheaval, now known as Reformasi, Suharto was brought down and a more democratic regime installed.
From their declaration of their independence Indonesia claimed West Papua as part of their nation, but the Dutch held onto it into the 1960s, and in the early sixties there was armed conflict over it. After a UN-brokered peace deal, and a referendum, West Papua became part of Indonesia and was renamed as Irian Jaya, which apocryphically stands for Ikut (part of) Republic of Indonesia, Anti Netherlands.
The former Portuguese colony of East Timor was annexed by Indonesia in 1975, but there was armed resistance to this. After decades of civil war, on 30 August 1999, a provincial referendum for independence was overwhelmingly approved by the people of East Timor. Indonesia grundgingly but still astonishingly accepted the result (after nevertheless looting the capital Dili), and East Timor gained its independence in 2002.