After India and China, Indonesia was the biggest new nation-state to emerge in the mid-twentieth century. Consisting of thousands of islands large and small, it sprawls roughly the same distance as that from Washington, D.C., to Alaska, and contains the largest Muslim population on earth. Yet, on our mental map of the world, the country is little more than a faraway setting for earthquakes, tsunamis, and volcanic eruptions. The political traumas of post-colonial Egypt, from Suez to el-Sisi, are far better known than the killing, starting in 1965, of more than half a million Indonesians suspected of being Communists or the thirty-year insurgency in Aceh Province. Foreign-affairs columnists, who prematurely hailed many revolutions at the end of the Cold War (Rose, Orange, Green, Saffron), failed to color-code the dramatic overthrow, in 1998, of Suharto, Indonesia’s long-standing dictator. They have scarcely noticed the country’s subsequent transfers of power through elections (there was one earlier this month) and a radical experiment in decentralization. The revelation that, from 1967 to 1971, Barack Obama lived in Jakarta with his mother, a distinguished anthropologist, does not seem to have provoked broadened interest in Indonesian history and culture—as distinct from the speculation that the President of the United States might have been brought up a Muslim.

Indonesia’s diversity is formidable: some thirteen and a half thousand islands, two hundred and fifty million people, around three hundred and sixty ethnic groups, and more than seven hundred languages. In this bewildering mosaic, it is hard to find any shared moral outlooks, political dispositions, customs, or artistic traditions that do not reveal further internal complexity and division. Java alone—the most populous of the islands, with nearly sixty per cent of the country’s population—offers a vast spectacle of overlapping cultural identities, and contains the sediments of many world civilizations (Chinese, Indian, Middle Eastern, European). The Chinese who settled in the port towns of the archipelago in the fifteenth century are a reminder of the great maritime network that, long before the advent of European colonialists, bound Southeast Asia to places as far away as the Mediterranean. Islam is practiced variously, tinged by the pre-Islamic faiths of Hinduism, Buddhism, and even animism. The ethnic or quasi-ethnic groups that populate the islands (Javanese, Batak, Bugis, Acehnese, Balinese, Papuan, Bimanese, Dayak, and Ambonese) can make Indonesia seem like the world’s largest open-air museum of natural history.

As Elizabeth Pisani writes in her exuberant and wise travel book “Indonesia Etc.” (Norton), this diversity “is not just geographic and cultural; different groups are essentially living at different points in human history, all at the same time.” In recent years, foreign businessmen, disgruntled with rising costs and falling profits in India and China, have gravitated to Indonesia instead. About half the population is under the age of thirty, and this has stoked excited conjecture in the international business media about Indonesia’s “demographic dividend.” And it is true that in Kalimantan, the Indonesian part of Borneo, once known for its ferocious headhunters, you can now find gated communities and Louis Vuitton bags. But the emblems of consumer modernity can be deceptive. While Jakarta tweets more than any other city in the world, and sixty-nine million Indonesians—more than the entire population of the United Kingdom—use Facebook, a tribe of hunter-gatherers still dines on bears in the dwindling rain forests of Sumatra, and pre-burial rites in nominally Christian Sumba include tea with the corpse.

This coexistence of the archaic and the contemporary is only one of many peculiarities that mark Indonesia as the unlikeliest of the nation-states improvised from the ruins of Europe’s empires after the Second World War. The merchants and traders of the Netherlands, who ruthlessly consolidated their power in the region beginning in the seventeenth century, had given the archipelago a semblance of unity, making Java its administrative center. The Indonesian nationalists, mainly Javanese, who threw the Dutch out—in 1949, after a four-year struggle—were keen to preserve their inheritance, and emulated the coercion, deceit, and bribery of the colonial rulers. But the country’s makeshift quality has always been apparent; it was revealed by the alarmingly vague second sentence in the declaration of independence from the Netherlands, which reads, “Matters relating to the transfer of power etc. will be executed carefully and as soon as possible.”

Indonesia, Pisani writes, “has been working on that ‘etc’ ever since.” To be fair, Indonesians have had a lot to work on. Building political and economic institutions was never going to be easy in a geographically scattered country with a crippling colonial legacy—low literacy, high unemployment, and inflation. The Japanese invasion and occupation during the Second World War had undermined the two incidental benefits of long European rule: a professional army and a bureaucracy. In the mid-nineteen-fifties, the American novelist Richard Wright concluded that “Indonesia has taken power away from the Dutch, but she does not know how to use it.” Wright invested his hopes for rapid national consolidation in “the engineer who can build a project out of eighty million human lives, a project that can nourish them, sustain them, and yet have their voluntary loyalty.” Indonesia did have such a person: Sukarno, a qualified engineer and architect who had become a prominent insurgent against Dutch rule. For a brief while, he formed—with India’s Jawaharlal Nehru and Egypt’s Gamal Abdel Nasser—a kind of Holy Trinity of the post-colonial world. But Sukarno struggled to secure the loyalty of the country’s dissimilar peoples. In the service of his nation-building project, he deployed anti-imperialist rhetoric, nationalized privately held industries, and unleashed the military against secession-minded islanders. He developed an ideology known as Nasakom (an attempted blend of nationalism, Islam, and Communism), before settling on a more autocratic amalgam that he called Guided Democracy.

By the early nineteen-sixties, Sukarno was worried about the military, which had been developing close links with the Pentagon, and he sought to establish a counterweight by strengthening the Partai Komunis Indonesia, at that time the largest Communist party outside the Soviet Union and China. But a series of still unclear events on the night of September 30, 1965, led to his downfall: several members of the military high command were murdered, provoking a counter-coup by a general named Suharto. The new rulers, Pisani writes, unleashed “a tsunami of anti-P.K.I. propaganda, followed by revenge killings.” The military zealously participated in the extermination of left-wing pests, and, as Pisani points out, “many ordinary Indonesians joined in with gusto.” Various groups—big landowners in Bali threatened by landless peasants, Dayak tribes resentful of ethnic Chinese—“used the great orgy of violence to settle different scores.” In Sumatra, “gangster organizations affiliated with business interests developed a special line in garroting communists who had tried to organize plantation workers.” The killings of 1965 and 1966 remain one of the great unpunished crimes of the twentieth century. The recent documentary “The Act of Killing” shows aging Indonesians eagerly boasting of their role in the exterminations.

This bloodletting inaugurated Suharto’s New Order—an even more transparent euphemism for despotism than Sukarno’s Guided Democracy had been. Suharto offered people rapid economic growth through private investment and foreign trade, without any guarantee of democratic rights. Styling himself bapak, or father, of all Indonesians, he proved more successful than other stern paternalists, such as the Shah of Iran and the Philippines’ Ferdinand Marcos. One of his advisers was a close reader of Samuel Huntington’s “Political Order in Changing Societies” (1968). The book’s thesis—that simultaneous political and economic modernization could lead to chaos—was often interpreted in developing countries as a warning against unguided democracy. Suharto, accordingly, combined hard-nosed political domination with an expanding network of economic patronage. In effect, he was one of the earliest exponents of a model that China’s rulers now embody: crony capitalism mixed with authoritarianism. He benefitted from the fact that the massacres had not only disposed of a strong political opposition but also intimidated potential dissenters among peasants and workers. According to Huntington, the historical role of the military in developing societies “is to open the door to the middle class and to close it on the lower class.” Suharto, together with his relatives and allies in the military and in big business, pulled off this tricky double maneuver for more than three decades, helped by the country’s wealth of exportable natural resources (tin, timber, oil, coal, rubber, and bauxite).