Occlumency: “The magical defence of the mind against external penetration. An obscure branch of magic, but a highly useful one.”
Severus Snape to Harry Potter in The Order of the Phoenix, Ch 24
While Harry is spending the Christmas holidays at the house of his godfather Sirius, his most hated teacher, Snape, turns up and delivers the very unwelcome message that during the next term, the Headmaster, Professor Dumbledore, wants Harry to take private Occlumency lessons from no other than Professor Snape.
‘Dumbledore wants to stop you having those dreams about Voldemort,’ said Hermione at once. ‘Well, you won’t be sorry not to have them any more, will you?’
‘Extra lessons with Snape?’ said Ron, sounding aghast. ‘I’d rather have the nightmares!’
When the lessons start, Snape explains things a bit further. The reason why Dumbledore wants Harry to learn Occlumency is that the Dark Lord (Voldemort) is “highly skilled at Legilimency”, which is “the ability to extract feelings and memories from another person’s mind”. (A Muggle would call it mind-reading, but in the wizarding world it gets a little more physical.) Occlumency, on the other hand, “seals the mind against magical intrusion and influence”.
Since Harry has a rather emotional personality, he never gets very good at occlumency; but, to quote Dumbledore further on in the story: “in the end, it mattered not”, because he has other qualities that serve him better.
Snape, however, is sort of the embodiment of Occlumency; his character remains a mystery throughout the series, and where his true loyalty lay was one of the favourite subjects of debate while readers were waiting for the last book in the series.