The history of Indonesia has been shaped by its geographic position, its natural resources, a series of human migrations and contacts, wars and conquests, as well as by trade, economics and politics. Indonesia is an archipelagic country of 17,000 to 18 000 islands (8,844 named and 922 permanently inhabited) stretching along the equator in South East Asia. The country's strategic sea-lane position fostered inter-island and international trade; trade has since fundamentally shaped Indonesian history. The area of Indonesia is populated by peoples of various migrations, creating a diversity of cultures, ethnicities, and languages. The archipelago's landforms and climate significantly influenced agriculture and trade, and the formation of states. The boundaries of the state of Indonesia represent the 20th century borders of the Dutch East Indies.
Fossilised remains of Homo erectus and his tools, popularly known as the "Java Man", suggest the Indonesian archipelago was inhabited by at least 1.5 million years ago. Austronesian people, who form the majority of the modern population, are thought to have originally been from Taiwan and arrived in Indonesia around 2000 BCE. From the 7th century CE, the powerful Srivijaya naval kingdom flourished bringing Hindu and Buddhist influences with it. The agricultural Buddhist Sailendra and Hindu Mataram dynasties subsequently thrived and declined in inland Java. The last significant non-Muslim kingdom, the Hindu Majapahit kingdom, flourished from the late 13th century, and its influence stretched over much of Indonesia. The earliest evidence of Islamised populations in Indonesia dates to the 13th century in northern Sumatra; other Indonesian areas gradually adopted Islam which became the dominant religion in Java and Sumatra by the end of the 16th century. For the most part, Islam overlaid and mixed with existing cultural and religious influences.
Europeans such as the Portuguese arrived in Indonesia from the 16th century seeking to monopolise the sources of valuable nutmeg, cloves, and cubeb pepper in Maluku. In 1602 the Dutch established the Dutch East India Company (VOC) and became the dominant European power by 1610. Following bankruptcy, the VOC was formally dissolved in 1800, and the government of the Netherlands established the Dutch East Indies under government control. By the early 20th century, Dutch dominance extended to the current boundaries. The Japanese invasion and subsequent occupation in 194245 during WWII ended Dutch rule, and encouraged the previously suppressed Indonesian independence movement. Two days after the surrender of Japan in August 1945, nationalist leader, Sukarno, declared independence and became president. The Netherlands tried to reestablish its rule, but a bitter armed and diplomatic struggle ended in December 1949, when in the face of international pressure, the Dutch formally recognised Indonesian independence.