"Well, although I did not see the Riddle who came out of the diary, what you described to me was a phenomenon I had never witnessed. A mere memory starting to act and think for itself? A mere memory, sapping the life out of the girl into whose hands it had fallen? No, something much more sinister had lived inside that book. ... a fragment of soul, I was almost sure of it. The diary had been a Horcrux."
-- Albus Dumbledore (HBP23)
The Diary of Tom Riddle is a Dark Magic item which preserves his memory and a bit of his soul, and it became his first Horcrux.
It is one of the more interesting and dangerous Dark Magic items. This simple diary, originally purchased by Riddle in a Muggle shop on Vauxhall Road in London, was actually a Horcrux. Tom Riddle, who would soon thereafter become Lord Voldemort, placed one torn piece of his soul into the diary, hoping to preserve the work he’d done for years to find and open the Chamber of Secrets.
“The diary …My diary. Little Ginny’s been writing in it for months and months, telling me all her pitiful worries and woes — how her brothers tease her, how she had to come to school with secondhand robes and books, how —” Riddle’s eyes glinted “— how she didn’t think famous, good, great Harry Potter would ever like her…”
— The Horcrux spirit of Tom Riddle (CS17)
The diary appeared blank, but when someone wrote onto its blank pages, Tom Riddle as he was during his years at Hogwarts wrote messages back. Lucius Malfoy had kept the diary for years until he had a chance to plant it on Ginny Weasley, slipping it into her Transfiguration textbook. Tom used the diary to influence Ginny into reopening the Chamber and loosing the Basilisk. Harry Potter defeated this memory version of Tom Riddle by plunging the broken, poisoned fang of the Basilisk into the diary. When he did this, all the ink spewed out of it and with it poured out the Dark Magical enchantment (CS17). One of Voldemort’s Horcruxes was destroyed.
Harry discovered in his sixth year during lessons with Dumbledore that Tom Riddle had learned about Horcruxes from Professor Slughorn, who was Head of Slytherin at that time. Tom used the knowledge to create a horcrux after Myrtle was killed by the Basilisk in the bathroom (HBP20, HBP23).
Notes and interesting facts
J K Rowling about diaries:
My sister used to commit her innermost thoughts to her diary. Her great fear was that someone would read it. That's how the idea came to me of a diary that is itself against you. You would be confiding everything to pages that aren't inanimate.
-- J.K. Rowling, "Wild about Harry", Candis Magazine, November 2001)
Now, the diary to me is a very scary object, a really, really frightening object. This manipulative little book, the temptation particularly for a young girl to pour out her heart to a diary, which is never something I was prone to, but my sister was. The power of something that answers you back, and at the time that I wrote that I'd never been in an Internet chat room. But I've since thought "Well it's very similar." Just typing your deepest thoughts into the ether and getting answers back, and you don't know who is answering you. And so that was always a very scary image to me, in the book, and I thought it worked very well in the film. You could understand when he started writing to see these things coming back to him, and the power of that, that secret friend in your pocket.
-- J.K. Rowling (Chamber of Secrets DVD Interview 2003)
From the Web
Harry Potter Wiki: T. M. Riddle's Diary
Candis Magazine, Jennie Renton, 1 November 2001: "Wild About Harry"
Newsround, Steve Kloves, 3 February 2003: DVD interview
WizardingWorld (Pottermore) features: Unravelling the riddle of Tom