War and Peace is set during the Napoleonic Wars at the beginning of the nineteenth century. The novel opens at a St Petersburg evening party in 1805, where the guests discuss the alliance between Russia and Austria against Napoleon, who is steadily advancing through Europe. Pierre, the vague, socially awkward illegitimate son of a count, meets his old friend Prince Andrei Bolkonsky, a cold, ambitious and intelligent young man, and they leave the party together with Prince Andrei's pregnant wife, whom Andrei inexplicably hates. Andrei is in the army, about to leave for the front line. Later on, Pierre joins his dissolute friends Anatole Kuragin and Dolokhov.

In Moscow, we are introduced to the aristocratic Rostov family: Natasha, a lively, happy girl, Nikolai, a hussar in the army, their young brother Petya, dull Vera, the oldest, and their cousin Sonya. Their parents are kind but terrible with money, squandering it on lavish balls and through their generosity to friends and relations.

Pierre's father Count Bezhukov dies, and Pierre inherits his vast wealth and title. He is swiftly surrounded by the grasping Kuragin family headed by Prince Vasili, and married off to beautiful, vacant Helene Kuragin, sister of Anatole. Soon Pierre discovers she is having an affair with his friend Dolokhov. The two men duel, and Pierre almost kills his rival.

Meanwhile Nikolai Rostov and Prince Andrei join the Russian army abroad. Prince Andrei is wounded at the Battle of Austerlitz; for a while everyone believes him to be dead. When he arrives back at his father's estate in Russia, he finds his wife in labour. She gives birth to a son, Nikolai, but dies immediately afterwards. The son is brought up by Prince Andrei's sister, Princess Marya, at their father's house. Marya is a shy, spiritual woman who is terrorised by her father, the strict and irritable Prince Nikolai.

Pierre leaves his wife and becomes a Freemason. He attempts to reform his huge estates, but is extremely ineffectual. Prince Andrei also becomes involved in reform, working with Speransky in St Petersburg, but both men eventually lose faith in their endeavours.

The Rostovs's finances worsen, especially after Nikolai runs up a massive gambling debt to Dolokhov. Nikolai is put under pressure to marry a rich heiress, but he and his cousin, Sonya, have been unofficially engaged since childhood, so he resists. Natasha meets Prince Andrei at a ball, and they fall in love. But Prince Andrei's father forces them to delay the wedding for a year. Andrei is still suffering from the wounds he received at Austerlitz and travels abroad to find treatment. His sister Marya has been approached by the dissolute Anatole Kuragin, whose father insists that he makes a wealthy match, but she refuses him, devoting herself to her father.

Having briefly made peace with Russia, in 1812 Napoleon decides to invade. Russia seems to be on the brink of total destruction. Natasha miserably waits for Andrei, missing him terribly. However, shortly before their separation is over, she meets Anatole Kuragin at the opera and feels attracted to him. They arrange to elope, even though the immoral Anatole is already secretly married. Luckily Sonya discovers their plan and stops it. Realising the mistake she has made, Natasha is overwhelmed with regret and falls dangerously ill.

Pierre tries to comfort Natasha, and falls in love with her himself, though he suppresses the feeling. He attempts to reunite with his wife, but she eventually asks for their marriage to be annulled, only to die shortly afterwards. Pierre is driven a little mad by these events. As the French army approaches Moscow, he becomes obsessed with the idea of assassinating Napoleon. Prince Andrei, devastated by Natasha's betrayal, rejoins the army, chasing Anatole Kuragin so he can challenge him to a duel and kill him.

The Russians under General Kutuzov meet Napoleon's army at the Battle of Borodino, an epic clash that lasts over two hundred pages. Once again, Prince Andrei is seriously wounded in battle. He finally catches up with Anatole in a field hospital, only to find that the latter has lost a leg. Prince Andrei has an epiphany brought on by the nearness of death and no longer hates him. As his health fails, he becomes more and more preoccupied by questioning the meaning of life and death.

Prince Andrei's father dies as the French approach his estate. Princess Marya, left alone, faces a rebellion of the serfs on Prince Andrei's land nearby. She is saved by Nikolai Rostov, and they find that they are attracted to each other. Nikolai realises that he no longer wants to marry Sonya.

As Napoleon approaches Moscow the rest of the Rostovs pack up, preparing to flee, but then decide to abandon their possessions so they can take casualties from Borodino with them. Soon afterwards, they realise that Prince Andrei is among the wounded soldiers. Natasha helps to nurse him, and they are reconciled. Princess Marya joins them, but Prince Andrei dies of his injuries.

Pierre stays in Moscow as Napoleon invades, looking for a chance to perform his assassination. He becomes increasingly detached from reality, wandering the streets and attempting to conceal his identity, until he decides on a whim to save a child from a burning building; most of Moscow is on fire. Pierre is arrested as an arsonist, and is sent to prison, where he meets a peasant, Platon Karataev, the epitome of homely, earthy wisdom. The prisoners are dragged away with the French army as they retreat from Moscow, and Karataev is shot as a straggler. Later, Pierre is rescued by a band of Russian partisans including the young Petya Rostov, who has also joined the army. However Petya dies in the attack that saves Pierre.

The French withdraw from Russia, and Napoleon is defeated. Nikolai Rostov, now a war hero, inherits his father's estates and sets about repaying debts and restoring his family's fortune. Pierre takes time to recover from his imprisonment, and then meets Natasha again, and they fall in love and get married. Eventually Nikolai stabilises his family's affairs and marries Princess Marya.

In the epilogue, the happy, peaceful family lives of these couples is described, but it is hinted that Pierre and Prince Andrei's son Nikolai Bolkonsky may go on to take part in the Decembrist Uprising against their autocratic government. In the second part of the epilogue, Tolstoy elaborates upon his theory of history: that historical events are so complex it is foolish to believe they can be altered by individuals, even ones as powerful as Napoleon.