The military history of Indonesia includes the military history of the modern nation of Republic of Indonesia, as well as the military history of the states which preceded and formed it. It encompassed a kaleidoscope of conflicts spanning over a millennium. The ancient and medieval part of it began as tribal warfare began among indigenous populations, and escalated as kingdoms emerged. The modern part is defined by foreign colonial occupations, battles for independence through guerrilla warfare during Indonesian National Revolution, regional conquests and disputes with neighbouring countries, as well as battles between the Republic and separatist factions. Since the formation of the Republic, the military has played significant role in state affairs. However, in Post-Suharto era, the Indonesian military has retreated from politics, yet it still possesses some influences.

As an archipelagic nation, historically Indonesia has always been a maritime power since Srivijaya and Majapahit era. The 7th century Srivijayan empire for example, thrived by maximizing the potential of the sea. During its early formation until the Suharto's New Order era, Indonesian military was heavily focused on its land component. However, by the 21st century, its interest has shifted to maritime sphere, as in 2014 President Joko Widodo has expressed a desire to turn Indonesia into a "maritime axis".

Prehistoric warfare

Archaeological findings dating from prehistoric eras have discovered a variety of stone and metal weaponry, such as axes, arrows and spearheads. Usually used for hunting, they also allowed tribes to battle with each other. Some more elaborate bronze pieces, such as axes, seemed better suited for ceremonial purposes, but showed its influence as an icon. Native edged weapons, such as the parang, klewang, mandau, badik, pedang, kujang, golok and kris, were invented early.

Tribal warfare, although often motivated by resources, lands and slave grabbing, was also a tribal solution to settling disputes, as well as a component of coming of age rituals (headhunting) for several tribes, primarily the Dayak, Nias and Batak. Warriors from militaristic tribes were appreciated by other factions, and were recruited by developed kingdoms and polities as mercenaries, such as Nias warriors serving as palace guards in the Aceh Sultanate, as well as Ambonese warriors recruited by the Dutch East India Company.

Tribal wars still occur amongst Papuan tribes in West Papua, as well as more remote areas of Nusantara, such as the interior of Borneo and Sumatra.

Ancient kingdoms Greek and Chinese sources mentioned that the people of the archipelago already building large ships from at least 2nd century A.D., the ships could be over 50 m in length and had 5.2–7.8 m high freeboard. These ships are called kolandiaphonta by the Greeks and K'un-Lun po by Chinese.

As ancient kingdoms began to form in Indonesia, at least as early as 7th century B.C., standing units became increasingly prevalent in the region. Indianised Hindu-Buddhist kingdoms saw the establishment of the Hindu Kshatriya caste. Bas reliefs on Javanese temples dating back to the Mataram kingdom, particularly Borobudur and Prambanan, depict battles and soldiers wielding various types of weapons. These weapons were primarily sharp-edged, such as spears, swords, sabre, klewang, golok, as well as stabbing daggers (seeming predecessors to kris). However, blunt weapons such as the Gada, shields, bows and arrows were also depicted.

Major Indonesian empires such as Srivijaya and Majapahit were known to launch naval raids against neighbouring kingdoms. Bas reliefs from their period depict double outriggered ships, now called cadik. These reliefs show that some kingdoms developed navies and even armadas.

These ancient kingdoms also developed martial arts for use in self-defence and warfare. They are collectively known today as pencak silat.

Srivijaya and Mataram

Many inscriptions were found that mention Srivijayan activity in the 7th century. The Kedukan Bukit inscription is the oldest record of Indonesian military history, and noted a 7th-century Srivijayan siddhayatra expedition led by Dapunta Hyang Sri Jayanasa. He was said to have brought 20,000 troops, including 200 seamen and 1,312 foot soldiers. The Telaga Batu inscription mentions military titles; such as senāpati (general), cātabhata (soldier), puhāvam (ship captain) and vāsīkarana (blacksmith/weapon maker). It revealed that the empire had specialised military units and formal military occupations. The Kota Kapur inscription mentions a Srivijayan naval expedition against Bhumi Java, and is dated to a period coinciding with the fall of the Tarumanagara and Kalingga kingdoms in Java.

In the 8th century CE, a Javanese launched various naval raids against Cham ports in Indochina. The Javanese continued to dominate areas around present-day Cambodia until the Khmer King Jayavarman II, the founder of the Khmer Empire dynasty, severed the Javanese link later in the same century. In 851 an Arabic merchant named Sulaimaan recorded an event about Javanese Sailendras staging a surprise attack on the Khmers by approaching the capital from the river, after a sea crossing from Java. The young king of Khmer was later punished by the Maharaja, and subsequently the kingdom became a vassal of Sailendra dynasty. In 916 CE, Abu Zaid Hasan mentioned that a polity called Zabag invaded the Khmer kingdom, using 1000 "medium-sized" vessels, which resulted in a Zabag victory. The head of the Khmer king was then brought to Zabag. Regardless of whether the story was true or not or just a legend, it may have a connection with the independence of Cambodia from Javanese suzerainty in 802 CE. Zabag might corresponds to Jawaka/Javaka, which may refer to Java or South Sumatra.

The 10th-century Arab account Ajayeb al-Hind (Marvels of India) gives an account of invasion in Africa by people called Wakwak or Waqwaq, probably the Malay people of Srivijaya or Javanese people of Mataram kingdom,Lombard, Denys (2005). Nusa Jawa: Silang Budaya, Bagian 2: Jaringan Asia. Jakarta: Gramedia Pustaka Utama. An Indonesian translation of Lombard, Denys (1990). Le carrefour javanais. Essai d'histoire globale (The Javanese Crossroads: Towards a Global History) vol. 2. Paris: Éditions de l'École des Hautes Études en Sciences Sociales. in 945–946 CE. They arrived in the coast of Tanganyika and Mozambique with 1000 boats and attempted to take the fortress of Qanbaloh, though eventually failed. The reason for the attack is because that place had goods demanded by their country and China, such as ivory, tortoise shells, panther skins, and ambergris, and also because they wanted black slaves from Bantu people (called Zeng or Zenj by Arabs, Jenggi by Javanese) who were strong and make good slaves.Kumar, Ann (2012). 'Dominion Over Palm and Pine: Early Indonesia's Maritime Reach', in Geoff Wade (ed.), Anthony Reid and the Study of the Southeast Asian Past (Singapore: Institute of Southeast Asian Studies), 101–122. The existence of black Africans was recorded until the 15th century in Old Javanese inscriptions and the Javanese were still recorded as exporting black slaves during the Ming dynasty era. According to Waharu IV inscription (931 AD) and Garaman inscription (1053 AD),Nastiti (2003), in Ani Triastanti, 2007, p. 39.Nastiti (2003), in Ani Triastanti, 2007, p. 34. the Mataram kingdom and Airlangga's era Kahuripan kingdom (1000–1049 AD) of Java experienced a long prosperity so that it needed a lot of manpower, especially to bring crops, packings, and send them to ports. Black labor was imported from Jenggi (Zanzibar), Pujut (Australia), and Bondan (Papua). According to Naerssen, they arrived in Java by trading (bought by merchants) or being taken prisoner during a war and then made slaves.Kartikaningsih (1992). p. 42; in Ani Triastanti (2007), p. 34.

In the late 10th century, animosity between the Sumatran Srivijaya and Javanese Mataram kingdom escalated. The Anjukladang inscription, dated to 937, commemorated the Javanese Mataram successful effort to repel Srivijayan attack. In 990 AD, King Dharmawangsa of Mataram launched a naval invasion against Srivijaya, and unsuccessfully attempted to capture Palembang. Dharmawangsa's invasion led the Maharaja of Srivijaya, Sri Cudamani Warmadewa to seek protection from China. His diplomatic skills saw him securing Chinese support through appeasement, by building a Buddhist temple to honour the Chinese emperor. In 1006 AD, Srivijaya successfully repelled the Javanese invasion, and in retaliation and alarm, assisted Haji (king) Wurawari of Lwaram to revolt, destroying the Mataram palace. With the death of Dharmawangsa and the fall of the Mataram capital, Srivijaya collapsed the Mataram kingdom.

In 1025 Rajendra Chola, the Chola king from Coromandel in South India, launched naval raids on ports of Srivijaya and conquered Kadaram (modern Kedah) from Srivijaya. Further battles with the Chola dynasty marked the decline of Srivijayan military might.

Majapahit

After defeating Srivijaya's successor, the Dharmasraya kingdom, in Sumatra on 1275, the kingdom of Singhasari in Java became the most powerful kingdom in the region. King Kertanegara launched the Pamalayu expedition against Sumatran states and conquered them. Having taken notice of these conquests, the Mongol Yuan dynasty of China demanded tribute to be sent to Kublai Khan's court by Java. Kertanegara responded by insulting and torturing Khan's envoy, and Kublai Khan sent an armada of 1000 ships in retaliation.

Meanwhile, Jayakatwang, the ruler of the Gelang-Gelang (Kediri) kingdom, revolted against Kertanegara, killing him and destroying the Singhasari kingdom. Raden Wijaya, the son in law of Kertanegara, led Mongol forces during the Mongol invasion of Java to Jayakatwang to oust him. Raden Wijaya then turned back against Mongol forces, and drove them out to the sea. Raden Wijaya then established the Majapahit kingdom in 1293. Majapahit would be plagued by regional rebellions, such as the rebellions of Sadeng and Keta, rebellion of Ranggalawe, and Nambi. After that, under the able and aggressive leader Gajah Mada, Majapahit spread its influence beyond Java and Sumatra, to the rest of the Nusantara archipelago.