For Leo Tolstoy and his extended household, diaries were an early version of Facebook. Everyone had his or her own page, and most people were fanatical recorders of their own feelings. The great man himself kept voluminous diaries, making entries almost to the day of his death. His doctor, his secretary, his disciples, his children, and – most of all – his wife also kept journals. Of these, the greatest diarist of them all was Sofia, the Countess Tolstoy.

She began keeping diaries at 16 but did so avidly after 1862, when she married Tolstoy. She never stopped writing in her journal until her death in 1919, as the Bolshevik revolution threatened to overwhelm Yasnaya Polyana, the 4,000-acre estate where she had lived for more than half a century. "There was a meeting to decide how best to defend Yasnaya Polyana against looting," she writes in her final entry. "Nothing has yet been decided. Carts, oxen and people are streaming down the highway to Tula." History, as it were, threatened to destroy everything she loved.

Tolstoy was of noble lineage, with a large estate and many celebrated books to his name. He had travelled widely in the west, and gambling and whoring were particular obsessions. Yet he seemed willing, even eager, to settle down with an innocent girl of 19, who eventually bore him 13 children, helped him in his work (she personally copied out War and Peace as well as Anna Karenina many times), and supervised a complex estate.

It was a wild ride for Sofia, but she proved equal to the task. Her husband appreciated her intelligence, and she loved not only him but his reputation. It seemed, to her, a privilege to live in proximity to a man whose fame grew exponentially as he aged. The problem was that Tolstoy shifted gears dramatically in midlife, becoming a religious guru, turning his back on fiction. He evolved into a kind of saint, attracting disciples from around the world (including Gandhi). He shaped his own version of Christianity, discounting its miraculous aspects. Worse, from Sofia's viewpoint, he threatened to give away all his property, including the copyright to his work, to the Russian people. A psychodrama emerged, with Sofia battling Tolstoy's disciples for access to his soul. Her diaries become increasingly frenzied in the 1880s and 90s, and the last decade of Tolstoy's life (1900-1910) makes for harrowing reading, as in this entry for 19 November 1903:

I went to [my husband's] room this evening as he was getting ready for bed, and realised I never hear a single word of comfort or kindness from him nowadays.

What I predicted indeed has come true: my passionate husband has died, and since he was never a friend to me, how could he be one to me now? This life is not for me. There is nowhere for me to put my energy and passion for life; no contact with people, no art, no work – nothing but total loneliness all day.

She sees herself as surrounded by "the raving of lunatics". All the talk around her was of celibacy, vegetarianism, and political resistance. Her husband had become his followers, and they crowded around, camping outside the manor house, pestering for interviews, taking photographs, telling the whole world that Sofia and Leo Tolstoy were at odds. She wondered if other people really needed to know her private business. One reads the earlier diaries with a sense of nostalgia for a lost world. On 4 October 1878, she wrote:

My daughter Tanya's fourteenth birthday. As soon as I got up I walked to the little plantation where the children were having a picnic . . . There were four bonfires . . . We had enormous fun and ate a lot, and we had magnificent weather. We got home and were just starting a game of croquet when what should we see but a procession of horses and donkeys filing along our "prospect" . . . The children were tremendously excited and immediately rushed over, leapt on the donkeys and started riding about on them . . . We drank Tanya's health in champagne; she blushed but was very pleased.

Life among the Tolstoys was good (one can find out who the characters are in these entries by searching the excellent footnotes provided by translator Cathy Porter). It consisted of dinner parties, teas, balls, picnics, hunting expeditions, concerts, theatrical outings (opera was a particular interest for Sofia), and long walks or rides in the countryside. Winters were usually spent in a townhouse in Moscow. It was all very grand, and – eventually – the propensity for self-indulgence disgusted Tolstoy, and he rejected this life, surrounding himself with like-minded people.

For her part, Sofia could not stand her husband's circle. "What unattractive types Lev Nikolaevich's followers are! There is not one among them who is normal. And most of the women are hysterics." He seems often very icy with her, as in this incident noted on 5 February 1895. She and her husband, whom she calls by the intimate name of Lyovochka, have gone out to shoot snipe:

Lyovochka was standing behind one tree . . . and I asked him why he didn't write anymore. And he stooped down, looked around in a rather comical way and said, "Nobody can hear us but the trees I think, my dear." (He called every­ one "my dear" as he got older.) "So I shall tell you. You see, before I write something new I need to be inflamed by love – and that's all over now!"

"What a shame!" I said, adding as a joke "You can fall in love with me if you like, then you could write something!"

"No, it's too late!" he said.

As one quickly sees, Sofia was herself a gifted writer. Without apparent effort, she draws countless portraits of her contemporaries, and it's fascinating to get her view of Tolstoy's encounters with such figures as Turgenev or Chekhov. His large world passes before us in scene after scene. And there is often a great deal of tension, as Tolstoy seemed always at odds with someone or something, including church and state. Increasingly the Tolstoy estate became the centre of a movement that prefigured the revolution of 1917. Sofia did not approve, as she could see that many of his followers were using him for their own political ends.

She is often quite revolutionary in her own way, however, as on the subject of the rights of women: "I was wondering today why there were no women writers, artists or composers of genius," she writes on 12 June 1898. "It's because all the passion and abilities of an energetic woman are consumed by her family, love, her husband – and especially her children. Her other abilities are not developed, they remain embryonic and atrophy. When she has finished bearing and educating her children her artistic needs awaken, but by then it's too late."

It was certainly too late for Sofia. A woman of intense feeling, a devoted wife and mother, someone who loved music and the arts, she had to contend with what she considered a gang of lunatics. She watched her husband slipping away from her, and was left on her own when, at 5am on 28 October 1910, Tolstoy stole away from his beloved estate, leaving his wife of 48 years. He would die in a tiny railway station some 80 miles from home, surrounded by his closest disciples, who refused Sofia entry when she tracked him down shortly before his death on 7 November.

The dramatic flight of Tolstoy at the end is a story of its own, largely ignored by Sofia in her diaries: she was too distraught to record the details. But the hundreds of pages offered by Porter in this selection are testament to a great spirit, a woman who lived in terrifying proximity to one of the greatest writers of all time, and who understood exactly the high price she would have to pay for this privilege.

Jay Parini's novel about Tolstoy, The Last Station, is published by Canongate.