Magadha was an ancient kingdom located on the Indo-Gangetic plains in eastern India and spread over what is today the modern state of Bihar. At the height of its power, it claimed suzerainty over the entire eastern part of the country (roughly the area of England) and ruled from its capital at Pataliputra (modern Patna, Bihar).
In 326 BCE, when Alexander the Great was camped at the river Beas on the westernmost part on India, his army mutinied; they refused to march further east. They had heard about the great Magadha kingdom and were unnerved by stories of its might. Unwillingly, Alexander turned back (and was to die en route). But this was not the first time that the might of Magadha had forced kings westwards. One of the earliest references to Magadha is in the epic Mahabharata, where we see the entire Yadava clan abandoning their homeland on the Gangetic plains to migrate south-westwards towards the desert-ocean land to avoid constant battles with their eastern neighbour, Magadha.
Ancient Magadha, & Jarasandha
The Magadha kingdom did not seem to have been liked by the vedic people. In the Atharva Veda, a charm against virulent fever speaks somewhat sarcastically of banishing the fever to the people of Magadha, inter alia.
गंधारिभ्यो मूजवद्भ्यो अड़ेभ्यो मगधेभ्यः ॥ प्रैष्यन्जनमिव शेवधि तक्मानं परि दध्मसि ॥
Over to the Gandharis, the Magavants, the Angas, and the Magadhas, do we deliver the fever, like a servant, like a treasure. [Atharva Veda, V.22.14]
In the Mahabharata, Magadha is the mightiest kingdom in the country, stronger even than the Kurus (of whom the epic is all about). Magadha controlled the entire eastern part of the country through alliances with smaller vassal states. It was constantly at war with its western neighbours, the Yadavas of Mathura, who ultimately migrated far west to the sea coast near the Rann of Kutch (modern Gujarat) because they could no longer afford the resources needed to protect their kingdom from the regular onslaughts of the Magadha king, Jarasandha.
This flight meant that Magadha's borders extended right up to the Kuru-Panchal kingdoms, where lived the Pandavas and the Kauravas. Jarasandha had powerful allies around his main kingdom: to the southwest was the vassal state of Chedi (to the south of which was another ally, Vidarbha), to the east were the allies of Anga and Vanga, and further east was the friendly country of Pragjyotishpur (modern Assam), ruled by a demon whose borders extended right up to China. This entire stretch of land looked to Jarasandha as their overlord.
The capital of Magadha was Girivraja (modern Rajgir, Bihar). This city was surrounded by rings of mountains and was, therefore, difficult to lay siege to. Jarasandha had imprisoned 99 minor kings, and had intended to offer a big human sacrifice after the 100th king was captured but, before he could do so, he was defeated in a wrestling match by the Pandava Bheema, and ripped apart into two. Jarasandha's son was placed on the throne but was later to die fighting for the Pandavas in the Kurukshetra war.
After the Kurukshetra war, the power of Magadha seems to have diminished somewhat because there are references to it being annexed by a south-western neighbour, Avanti. It continued to be an important kingdom, however, and was counted among the 16 principal states of ancient India.
Magadha at the Time of the Buddha
At around the time that Gautama Siddhartha became the Buddha, Magadha was a flourishing kingdom under its king Bimbisara. Under Bimbisara, Magadha annexed the neighbouring eastern kingdoms, and made marriage aliances with the ones in the west and north. He was friends with another neighbour, Avanti, to whose king he sent his own physician when the Avanti king was ill. The country was ruled by the king with help from three classes of officials: the executive, the judiciary, and the military. It was during Bimbisara's rule that Gautama Siddhartha, the heir-prince of a country north of Magadha, came there wandering, seeking the eternal truth, and attained enlightenment at Bodhi Gaya to become the Buddha.
Bimbisara was succeeded by his son Ajatashatru, who shifted the capital of Magadha from Girivraja to Pataliputra (modern Patna, Bihar). Ever since, Pataliputra has remained the capital of that province, down to this day. Ajatashatru also expanded his father's territories considerably; he annexed Kosala, the Lichchhavi republic, Kashi, and Avanti. Some of these kingdoms were related to him by blood but Ajatashatru is generally depicted as a cruel person not given to family niceties (he had deposed and imprisoned his father to ascend the throne).
The battle with the Lichchhavi republic was a long-drawn out affair, and we have descriptions of some of the military innovations that Ajatashatru implemented: one was a catapult that could throw heavy stones a great distance (mahashilakantaka), and another was a self-propelling, covered chariot that had rotating spears and blades attached to its wheels (rathamushal). An interesting fallout of the Magadha-Lichchhavi war was the affair of Ajatashatru with the Lichchhavi state courtesan Amrapali. The destruction of the Lichchhavi lands by Magadha so pained Amrapali that she became a Buddhist nun; her son by Ajatashatru went on to become a Buddhist monk.
Ajatashatru was against the Buddha to begin with but became a friend later. When the Buddha died and his remains were distributed among his disciples, a major share fell to Ajatashatru who was the most powerful king of that period. He enshrined the relics inside a stupa at Girivraja. Later, he hosted the first ever council of Buddhist monks, when about 500 of them congregated at the Magadha capital for the Great Council.
There are conflicting reports about the successors of Ajatashatru but about 50 years after his death, the people of Magadha deposed the hereditory king and elected a minister named Shishunaga to the throne. Shishunaga was succeeded by his son, during whose reign the Second Buddhist Council was held in Magadha. The last king of the Shishunaga Dynasty was killed in a palace conspiracy and was succeeded by Mahapadma Nanda.
The Nandas
The origins of the Nandas is obscure; however, all of the texts of that period agree that Mahapadma Nanda, the kingslayer, was of low birth and a paramour to one of the queens. He reconquered all of the lands that Magadha had lost under Ajatashatru's successors, and extended the kingdom to right inside the Deccan plateau of India. By the time that Alexander had invaded the western frontiers of India, the Nanda Dynasty had expanded Magadha to the Gangetic seacoast in the east and to the Punjab in the west.
Thus, if Alexander were to march any further east, he would have had have to reckon with a mighty kingdom having the full resources of the entire northern India under its control; Magadha's army consisted of 20,000 cavalry, 200,000 infantry, 2,000 chariots, and 3,000 elephants. Alexander's army mutinied; they refused to fight an army that formidable.
The Fall of Magadha
Despite the extreme wealth and the military might of Magadha, its king was hugely unpopular on account of his cruelty and the high rates of taxation he imposed on the populace. The Buddhist texts of the period say that the king was given to digging up the riverbed of the Ganges and burying his gold there. So enduring were stories of the fabulous wealth of the Nandas that Hieun Tsang, the Chinese pilgrim touring the country in the 7th century CE, almost 600 years later, makes a reference to it.
After Alexander left for Greece, the departure created a power vacuum in western India. Chandragupta Maurya stepped into this vaccuum, subjugated these kingdoms, and then entered Pataliputra and killed the Nanda king. The details of this overthrow are unclear but it is assumed that Chandragupta Maurya had the support of the populace and the palace. The mighty Magadha kingdom had given way to a kingdom even more powerful: the Mauryan Empire.