When Václav Havel first entered Prague Castle after becoming president of Czechoslovakia in 1989, he and his team ("a group of friends from various branches of the arts") found wires and concealed microphones everywhere, and a map revealing secret rooms. It was "an enchanted Kafkaesque castle" and, as he reveals in this candid memoir, his time there frequently struck him as absurd. What he most remembers from those heady, almost hysterical early days is that "we laughed a lot, though I can hardly remember what we laughed at or why". Yet the laughter soon died away, and this is primarily a book about disillusionment.

When Havel went from being a dissident to a president, "the arc of my story was completed in a way that was almost like a fairytale", he notes, adding that it was a narrative that played especially well in the west, where he assumed an almost legendary status. Back home, however, the fairytale swiftly came to an end - and it was not a happy ending. Havel had a country to run and he fell back to earth with a bump. In this book he attempts to answer his critics and to address his "murky legacy". Why didn't he root out communists from the government and make a clean break with the old regime? Why did it take a month to disband the secret police, giving them time to destroy files? Why did he release all prisoners, resulting in a rise in crime? Why did he let the nationalists triumph in Slovakia, leading to the break-up of Czechoslovakia? The criticisms piled up, and at one point he even had business cards printed that read "Václav Havel, Author of Many Mistakes and Errors".

As a playwright, he understood the theatrical nature of politics. All politicians must have "an elementary dramatic instinct", he writes. But a major theme in this book is how often this desire for structure and order is thwarted by events, dear boy, events. Whereas drama gives meaning and structure to existence, "Politics is more of a strange, never-ending process with no clear turning points and no unambiguous and immediately recognisable outcomes."

To the Castle and Back moves back and forth in time, mixing diary entries with Havel's answers to an interview and some "ancient memos" written to his staff from 1993 to 2003. One repeated request appears to symbolise the continued presence of the former regime: "In the closet where the vacuum cleaner is kept, there also lives a bat. How to get rid of it?"

After becoming president, Havel churned out a speech a week for almost 15 years, and this gruelling schedule snuffed out any remaining creative spark. "Perhaps it's because of all this hard labour that I now find writing so difficult," he observes. "I'm not the same person I was when I wrote my plays." In 2005 he mentions a play he wants to finish, which he began writing before the revolution, about a statesman who loses his position but cannot bear to leave his official residence. It would contain echoes of King Lear, The Cherry Orchard, Endgame. "Having thought about it for so long, I'll never get it written," he complains. Happily, we know that he did overcome his writer's block. Leaving premiered in Prague this spring and was hailed as a triumph.

"How wonderful it is, by comparison, to be a writer!" observes this disenchanted former president. "You write something in a couple of weeks, and it's here for the ages. What will remain when presidents and prime ministers are gone? Some references to them in textbooks, most likely inaccurate."