Image copyright AP Image caption JK Rowling's Harry Potter books have sold more than 450 million copies worldwide

GCHQ, the UK's surveillance agency, intervened to help prevent the sixth Harry Potter instalment leaking online, the book's publisher has said.

Bloomsbury's Nigel Newton said GCHQ contacted him in 2005 after it apparently discovered an early copy of The Half Blood-Prince on the internet.

However, after a page was read to an editor, it was determined to be fake.

A spokesperson for GCHQ told the Sunday Times: "We don't comment on our defence against the dark arts."

GCHQ, based in Cheltenham, Gloucestershire, is a secret intelligence agency which monitors electronic communication to prevent terrorism and tackle serious and organised crime.

There was much excitement surrounding the release of Harry Potter and the Half-Blood Prince after author JK Rowling hinted a major character would be killed off.

Mr Newton told Australia's ABC Radio the publisher regarded keeping the plot secret as very important saying: "If newspapers splashed 'Dumbledore dies' what pleasure is there going to be for a kid reading it? The enemies stood to ruin a great deal of pleasure for the world."

Image copyright PA Image caption Mr Newton told ABC Radio about how the first Harry Potter book was knocked back by 12 publishers before it came to Bloomsbury

It led Bloomsbury to bring in extra security guards and dogs to patrol the press where the books were being printed and help stop any leaks.

"We fortunately had many allies," Mr Newton said. "GCHQ rang me up and said, 'We've detected an early copy of this book on the internet'. I got them to read a page to our editor and she said, 'No, that's a fake'. We also had judges and the police on our side.

"It was completely mad and we were at the eye of the storm - I remember Jo Rowling phoning me once after she had delivered a new book saying, 'please will you release the name of the title because I have people outside searching my trash can looking for bits of paper'.

"We had to go into a complete security lockdown because people were trying to steal the manuscript."

Mr Newton also claimed a tabloid newspaper sent a reporter with £5,000 in cash to circle the printing press and offer workers money to steal a copy.

But the publisher hinted sometimes exceptions were made in giving out early copies ahead of publication.

"There was [an instance] where a child was going to die of an awful childhood condition before the book came out," he said. "So we did the only thing we could do and referred it to the author to decide how to handle it because it's her story, not ours.

"History doesn't tell the outcome of that sad story, but I'm sure it was a happy one."

The seven instalments in the Harry Potter series have sold more than 450 million copies worldwide, with another chapter in the story scheduled for release this summer on stage and in book form.