The Mahabharata is an ancient Indian epic where the main story revolves around two branches of a family - the Pandavas and Kauravas - who, in the Kurukshetra War, battle for the throne of Hastinapura. Interwoven into this narrative are several smaller stories about people dead or living, and philosophical discourses. Krishna-Dwaipayan Vyasa, himself a character in the epic, composed it; as, according to tradition, he dictated the verses and Ganesha wrote them down. At 100,000 verses, it is the longest epic poem ever written, generally thought to have been composed in the 4th century BCE or earlier. The events in the epic play out in the Indian subcontinent and surrounding areas. It was first narrated by a student of Vyasa at a snake-sacrifice of the great-grandson of one of the major characters of the story. Including within it the Bhagavad Gita, the Mahabharata is one of the most important texts of ancient Indian, indeed world, literature.
The prelude
Shantanu, the king of Hastinapur, was married to Ganga (personification of the Ganges) with whom he had a son called Devavrat. Several years later, when Devavrat had grown up to be an accomplished prince, Shantanu fell in love with Satyavati. Her father refused to let her marry the king unless the king promised that Satyavati's son and descendants would inherit the throne. Unwilling to deny Devavrat his rights, Shantanu declined to do so but the prince, on coming to know of the matter, rode over to Satyavati's house, vowed to renounce the throne and to remain celibate throughout his life. The prince then took Satyavati home to the palace so that the king, his father, could marry her. On account of the terrible vow that he'd taken that day, Devavrat came to be known as Bheeshm. Shantanu was so pleased with his son that he granted to Devavrat the boon of choosing the time of his own death.
In time, Shantanu and Satyavati had two sons. Soon thereafter, Shantanu died. Satyavati's sons still being minors, the affairs of the kingdom were managed by Bheeshm and Satyavati. By the time these sons reached adulthood, the elder one had died in a skirmish with some gandharvas (heavenly beings) so the younger son, Vichitravirya, was enthroned. Bheeshm then abducted the three princesses of a neighbouring kingdom and brought them over to Hastinapur to be wedded to Vichitravirya. The eldest of these princesses declared that she was in love with someone else, so she was let go; the two other princesses were married to Vichitravirya who died soon afterwards, childless
So that the family line did not die out, Satyavati summoned her son Vyasa to impregnate the two queens. Vyasa had been born to Satyavati of a great sage named Parashar before her marriage to Shantanu. According to the laws of the day, a child born to an unwed mother was taken to be a step-child of the mother's husband; by that token, Vyasa could be considered Shantanu's son and could be used to perpetuate the Kuru clan that ruled Hastinapur. Thus, by the Niyog custom, the two queens each had a son of Vyasa: to the elder queen was born a blind son called Dhritarashtra, and to the younger was born an otherwise healthy but extremely pale son called Pandu. To a maid of these queens was born a son of Vyasa called Vidur. Bheeshm brought up these three boys with great care. Dhritarashtra grew up to be the strongest of all princes in the country, Pandu was extremely skilled in warfare and archery, and Vidur knew all the branches of learning, politics, and statesmanship.
With the boys grown, it was now time to fill up the empty throne of Hastinapur. Dhritarashtra, the eldest, was bypassed because the laws barred a disabled person from being king. Pandu, instead, was crowned. Bheeshm negotiated Dhritarashtra's marriage with Gandhari, and Pandu's with Kunti and Madri. Pandu expanded the kingdom by conquering the sorrounding areas, and brought in considerable war booty. With things running smoothly in the country, and with its coffers full, Pandu asked his elder brother to look after the state affairs, and retired to the forests with his two wives for some time off.
A few years later, Kunti returned to Hastinapur. With her were five little boys, and the bodies of Pandu and Madri. The five boys were the sons of Pandu, born to his two wives through the Niyog custom from gods: the eldest was born of Dharma, the second of Vayu, the third of Indra, and the youngest - twins - of the Ashvins. In the meanwhile, Dhritarashtra and Gandhari too had had children of their own: 100 sons and one daughter. The Kuru elders performed the last rites for Pandu and Madri, and Kunti and the children were welcomed into the palace.