Located on the trade routes from India to East Asia, the Andaman and Nicobar island groups have been known from the earliest times. The 7th-century Chinese Buddhist monk I-ching, the Arab travelers of the 9th century, and Marco Polo (c. 1254–1324) are among those who mentioned the islands.

The name Andaman most likely is derived from the name of the monkey god of Hindu mythology, Hanuman. The name Nicobar probably derives from the Tamil word nakkavaram (“land of the naked”).

The navy of the English East India Company visited The Andaman Islands in 1789, and in 1872 they were merged administratively by the British to the Nicobar Islands. The two sets of islands became a union territory of the Republic of India in 1956. 

The British first surveyed the Andaman Islands in 1789 in search of a place to establish a penal colony for offenders from British India. Such a colony was established in 1790 but was abandoned just a few years later. In the mid-19th century, concern over native attacks on shipwrecked crews and the need for a penal settlement after the Indian Mutiny (1857–58) led the British to return to the Andamans.

In 1858 they founded a new penal colony, named Port Blair. It was during a visit to Port Blair that Lord Mayo, Viceroy of India (1869–72), was murdered by a convict in 1872. Meanwhile, the Danish, who had been the claimants of the Nicobar Islands—the ownership of which had since the 17th century shifted variously between France, Denmark, Austria, and Great Britain—relinquished their rights to the territory to the British in 1868.

The population of the region, particularly of the Andamans, was greatly changed by the settlement of convicts from the mainland and, beginning in the 1950s, of numerous refugees, especially from East Pakistan (since 1971, Bangladesh). Japanese forces occupied both the Andaman and Nicobar island groups from 1942 to 1945 (during World War II); after the British recaptured the islands, the penal colony in the Andamans was abolished.

Administration of the Andamans and Nicobar was passed to India when it gained independence in 1947. The Andaman Cellular Jail, where Indian political prisoners were held, was declared a national monument in 1979.

In 2004 the Andaman and Nicobar island groups were struck by a tremendous tsunami that had been generated by an earthquake in the Indian Ocean near Sumatra, Indonesia. The inundation left thousands of people dead and many more displaced. The lower-lying Nicobar was most severely affected, with significant portions of some of those islands submerged by the tidal wave.