What will happen yesterday?

During the Soviet era it used to be joked that Russia was the only country in which the past was unpredictable. When the secret police chief Lavrenti Beria was shot in 1953, libraries were ordered to cut out the pages of the Soviet encyclopedia that dealt with him and expand the section on the Bering Strait. As far as official Soviet history was concerned Beria had never existed and the events in which he had played a part had to be rewritten.

In the former Soviet Union history was repeatedly revised to reflect the changing pattern of power and the shifting party line, but rewriting the past is not a practice confined to totalitarian states. It goes on in regimes of all kinds, not least liberal democracies. Churchill's history of the second world war, Margaret Macmillan observes, is "a sweeping and magisterial account which glossed over many awkward issues". There is no mention in it of cabinet discussions in May 1940, when the issue of seeking peace through the mediation of Mussolini was actively debated. Fortunately for the future of civilisation the idea that peace could be made with the Nazis was rejected and Churchill prevailed; but his claim that the issue was never seriously deliberated is contrary to fact. The decision whether to fight on could easily have gone the other way, with unthinkable consequences for the world.

The official history that exaggerates British unity in 1940 is only one of many examples discussed by Macmillan, but it encapsulates one of the conclusions that emerge from her wise and enlightening book. While there will always be different perspectives on the past, we are not adrift in a sea of relativism. There are facts of the matter, which historians can sometimes establish. As Macmillan writes: "Memory is not only selective; it is malleable." For example, when writing his memoirs Dean Acheson remembered sitting in President Roosevelt's office with secretary of state Cordell Hull on the day in 1941 when the US froze Japanese assets and edged closer to war. Acheson's secretary checked the record, and found that Hull was not in Washington on the day. Memory is unreliable, but that does not mean the truth cannot be known.

Getting facts wrong - whether inadvertently or deliberately - is not the only way history can be misused. Making misleading analogies is another, and it often occurs when there is a need to justify entering into a risky conflict. Anthony Eden invoked the failure to resist Hitler at Munich when defending the Suez adventure in 1956, while some supporters of the Iraq war were ready to portray Saddam Hussein as a threat to world peace on a par with that posed by Hitler. Whatever their sins, neither leader possessed Hitler's vast industrial and military resources, or harboured his global ambitions. Yet misguided analogies of this kind recur in liberal democracies in much the same way that the outright falsification of history does in totalitarian regimes.

Macmillan is a distinguished historian who has written illuminatingly on topics as diverse as the 1919 Paris peace conference and Nixon in China. Perhaps more unusually she is also a gifted writer, and her account of the various uses of history is wonderfully accessible. Her message - that we cannot help invoking the past when we try to shape the future, but should use it with due caution and humility - is a salutary one for politicians. But it is not only political leaders who misuse the past. As Macmillan points out, Vladimir Putin has sponsored the writing of new "patriotic" history textbooks for use in schools, which downplay Stalin's crimes and focus instead on his role in protecting Russia from its enemies. In other words, Putin is distorting history in the service of power. From another angle, the Russian leader is doing no more than generations of western historians did when they consistently underestimated the casualties of the Stalin era. (They made the same mistake about Russia in the time of Lenin, but that is another story.)

When Robert Conquest published his account of the great terror in 1968, his report of the vast numbers that perished was attacked as being wildly exaggerated. In fact - as Conquest later showed - it was an underestimate. Believing that the USSR was in the end a progressive regime, many western historians have held back from confronting the full scale of the human costs of communism. In shying away from these facts history has also been misused - simply in order to sustain an illusion.

• John Gray's Gray's Anatomy is published by Allen Lane. To order The Uses and Abuses of History for £10.99 with free UK p&p call Guardian book service on 0330 333 6846 or go to theguardian.com/bookshop