The core story of the work is that of a dynastic struggle for the throne of Hastinapura, the kingdom ruled by the Kuru clan. The two collateral branches of the family that participate in the struggle are the Kaurava, the elder branch of the family, and the Pandava, the younger branch.
The struggle culminates in the Great battle of Kurukshetra, in which the Pandavas are ultimately victorious. The battle produces complex conflicts of kinship and friendship, instances of family loyalty and duty taking precedence over what is right, as well as the converse.
The Mahabharata itself ends with the death of Krishna, and the subsequent end of his dynasty, and ascent of the Pandava brothers to heaven. It also marks the beginning of the Hindu age of Kali (Kali Yuga), the fourth and final age of mankind, where the great values and noble ideas have crumbled, and man is heading toward the complete dissolution of right action, morality and virtue.
Janamejaya's ancestor Shantanu, the king of Hastinapura has a short-lived marriage with the goddess Ganga and has a son, Devavrata (later to be called Bhishma), who becomes the heir apparent.
Satyavati is the daughter of a fisherman in the kingdom, and she already has a son, Vyasa. Many years later, when the king goes hunting, he see her and asks to marry her. Her father refuses to consent to the marriage unless Shantanu promises to make any future son of Satyavati the king upon his death. To solve the king's dilemma, Devavrata agrees not to take the throne. As the fisherman is not sure about the prince's children honouring the promise, Devavrata also takes a vow of lifelong celibacy to guarantee his father's promise.
Shantanu has two sons by Satyavati, Chitrangada and Vichitravirya. Upon Shantanu's death, Chitrangada becomes king. After his death Vichitravirya rules Hastinapura. In order to arrange the marriage of the young Vichitravirya, Bhishma goes to Kashi for a swayamvara of the three princesses Amba, Ambika and Ambalika. He wins them, and Ambika and Ambalika are married to Vichtravirya.
Vichitravirya died young without any heirs. Satyavati then asked her first son Vyasa to go to the bed of Vichitravirya's widows. Vyasa fathered the royal children Dhritarashtra, who is born blind, and Pandu, who is born pale. Through a maid of the widows, he also fathers their commoner half-brother Vidura.
Pandu marries twice, to Kunti and Madri. Dhritarashtra is married to Gandhari, who blindfolds herself when she finds she has been married to a blind man. Pandu takes the throne because of Dhritarashtra's blindness. Pandu while out hunting deer, is however cursed that if engages in the sexual act, he will die. He then retires to the forest along with his two wives, and his brother rules thereafter, despite his blindness.
Pandu's elder queen Kunti however, asks the gods, Vayu, and Indra for sons, by using a boon granted by Durvasa. She gives birth to three sons Yudhishtira, Bhima, and Arjuna through these gods. Kunti shares her boon with the younger queen Madri, who bears the twins Nakula and Sahadeva through the Ashwini twins. However Pandu and Madri, unable to resist temptation, indulge in sex and die in the forest, and Kunti returns to Hastinapura to raise her sons, who are then usually referred to as the Pandava brothers.
Dhritarashtra has a hundred sons through Gandhari, the Kaurava brothers, the eldest being Duryodhana, and the second Dushasana. There is rivalry between the sets of cousins, from their youth and into manhood.
Duryodhana plots to get rid of the Pandavas and tries to kill the Pandavas secretly by setting fire to their palace which he had made of lac. However, the Pandavas are warned by their uncle, Vidura, who sends them a miner to dig a tunnel. They are able to escape to safety and go into hiding, but after leaving others behind, whose bodies are mistaken for them. Bhishma goes to the river Ganga to perform the last rites of the people found dead in the burned palace, understood to be Pandavas. Vidura then informs him that the Pandavas are alive and to keep the secret to himself.
In course of this exile the Pandavas are informed of a swayamvara, a marriage competition, which is taking place for the hand of the Panchala princess Draupadi. The Pandavas enter the competition in disguise as Brahmins. The task is to string a mighty steel bow and shoot a target on the ceiling while looking at its reflection in water below. Most of the princes fail, being unable to lift the bow. Arjuna, however, succeeds. When he returns with his bride, Arjuna goes to his mother, saying, "Mother, I have brought you a present!". Kunti, not noticing the princess, tells Arjuna that whatever he has won must be shared with his brothers. To ensure that their mother never utters a falsehood, the brothers take her as a common wife. In some interpretations, Draupadi alternates months or years with each brother. At this juncture they also meet Krishna, who would become their lifelong ally and guide.
After the wedding, the Pandava brothers are invited back to Hastinapura. The Kuru family elders and relatives negotiate and broker a split of the kingdom, with the Pandavas obtaining a new territory. Yudhishtira has a new capital built for this territory at Indraprastha. Neither the Pandava nor Kaurava sides are happy with the arrangement however.
Shortly after this, Arjuna marries Subhadra. Yudhishtira wishes to establish his position; he seeks Krishna's advice. Krishna advises him, and after due preparation and the elimination of some opposition, Yudhishthira carries out a Rajasuya Yagna ceremony; he is thus recognised as pre-eminent among kings.
The Pandavas have a new palace built for them, by Maya the Danava. They invite their Kaurava cousins to Indraprastha. Duryodhana walks round the palace, and mistakes a glossy floor for water, and will not step in. After being told of his error, he then sees a pond, and assumes it is not water, falls in, and is humiliated.
Sakuni, Duryodhana's uncle, now arranges a dice game, playing against Yudhishtira with loaded dice. Yudhishtira loses all his wealth, then his kingdom. He then even gambles his brothers, then his wife, and finally himself, into servitude. The jubilant Kauravas insult the Pandavas in their helpless state and even try to disrobe Draupadi in front of the entire court.
Dhritarashtra, Bhishma, and the other elders are aghast at the situation, and negotiate a compromise. The Pandavas are required to go into exile for 13 years, and for the 13th year must remain hidden. If discovered by the Kauravas, they will be forced into exile for another 12 years.
The Pandavas spend twelve years in exile. Many adventures occur during this time. They also prepare alliances for a possible future conflict. They spend their final year in disguise in the court of Virata, and are discovered at or after the end of the year.
At the end of their exile, they try to negotiate a return to Indraprastha. However, this fails, as Duryodhana objects that they were discovered while in hiding, and that no return of their kingdom was agreed. War becomes inevitable.
The two sides summon vast armies to their help, and line up at Kurukshetra for a war. The Kingdoms of Panchala, Dwaraka, Kasi, Kekaya, Magadha, Matsya, Chedi, Pandya and the Yadus of Mathura and some other clans like the Parama Kambojas were allied with the Pandavas. The allies of the Kauravas included the kings of Pragjyotisha, Anga, Kekaya, Sindhudesa (including Sindhus, Sauviras and Sivis), Mahishmati, Avanti in Madhyadesa, Madra, Gandhara, Bahlikas, Kambojas and many others. Prior to war being declared, Balarama, had expressed his unhappiness at the developing conflict, and left to go on pilgrimage, thus he does not take part in the battle itself. Krishna takes part in a non-combatant role, as chariot driver for Arjuna.
Before the battle, Arjuna, seeing himself facing great-uncle Bhishma and his teacher Drona on the other side, has doubts about the battle and he fails to lift his Gandiva bow. Krishna wakes him up to his call of duty in the famous Bhagavad Gita section of the epic.
Though initially sticking to chivalrous notions of warfare, both sides soon adopt into dishonourable tactics. At the end of the 18-day battle, only the Pandavas, Satyaki and Krishna survive.
After seeing the carnage, Gandhari who had lost all her sons, curses Krishna to be a witness to a similar annihilation of his family, for though divine and capable of stopping the war, he had not done so. Krishna accepts the curse, which bears fruit 36 years later.
The Pandavas who had ruled their kingdom meanwhile, decide to renounce everything. Clad in skins and rags they retire to the Himalaya and climb towards heaven in their bodily form. A stray dog travels with them. One by one the brothers and Draupadi fall on their way. As each one stumbles, Yudhishitra gives the rest the reason for their fall (Draupadi was partial to Arjuna, Nakula and Sahadeva were vain and proud of their looks, Bhima and Arjuna were proud of their strength and archery skills, respectively). Only the virtuous Yudhisthira who had tried everything to prevent the carnage and the dog remain. The dog reveals himself to be the god Dharma, who reveals the nature of the test and assures Yudhishtra that his fallen siblings and wife are in heaven. Yudhisthira alone reaches heaven in his bodily form for being just and humble.
Arjuna's grandson Parikshita rules after them and dies bitten by a snake. His furious son, Janamejaya, decides to perform a snake sacrifice () in order to destroy the snakes. It is at this sacrifice that the tale of his ancestors is narrated to him.