A man was jailed for four-and-a-half years today after stealing pre-release copies of a Harry Potter novel and shooting a blank-firing pistol at a journalist when he failed to negotiate a sale.

Aaron Lambert, 20, stole two copies of Harry Potter and the Half Blood Prince from a secure distribution centre on June 2 last year, six weeks before the JK Rowling novel's much awaited publication.

He had been working as a security guard at the TNT distribution warehouse in Corby, Northamptonshire, which was gearing up to deal with more than 10m copies of the book before its release on July 16 last year.

Lambert's plan was to try and sell copies of the book to the newspapers, hoping they would pay large sums of money to reveal the novel's secrets.

He thought he had arranged separate deals with the Sun and the Daily Mirror to sell the books, the sixth in the bestselling series written by J K Rowling, for £50,000 and £30,000 each.

But Lambert, a bodybuilding enthusiast who took steroids, was arrested the following day, on June 3, when the newspapers contacted the police.

Just before his arrest Lambert met with Sun reporter John Askill, who was planning to pretend he was negotiating a deal and then carry out a newspaper sting by fleeing with the books.

As Mr Askill tried to flee with the novels, Lambert brandished an imitation Walther PPK pistol and then fired it in the journalist's direction. Mr Askill heard a loud bang and became "very concerned for his safety", the prosecution said.

Matthew Brookes-Baker, prosecuting, said: "He [Mr Askill] said he really had the belief the defendant was going to use it and was very scared during all of this."

Armed police arrived and arrested Lambert after Mr Askill reported that the security guard had fired the imitation pistol at him.

At a hearing at Northampton crown court last month, Lambert, of Tresham Street, Kettering, pleaded guilty to theft and possessing an imitation firearm with intent to cause fear of violence.

Lambert also admitted trying to blackmail publishers Bloomsbury by threatening to reveal the contents of the novel. He made the blackmailing attempts while on bail after his arrest on June 3 in two telephone calls to Bloomsbury in which he demanded the publishers pay him to stay silent about the book's contents.

"[Lambert said] they should pay him by the end of the week or he would be telling people about the book," Mr Brookes-Baker told the court.

"He said, 'I could really fuck her up,' meaning JK Rowling in respect of information gleaned from the book. 'They need to pay me to shut my mouth. I do not care if it is legal."'

Lambert was jailed for 12 months for theft, 18 months for the firearms offence and two years consecutive for the blackmail.

Delivering sentence, Judge Richard Bray told Lambert: "It was only through the good services of the press and police that this was prevented and fans of Harry Potter, young and old, were able to read this book without their pleasure being polluted."

Judge Bray said Lambert's "bizarre" crimes were ultimately doomed to fail but had caused considerable fear for those involved.

The judge said: "I have to sentence you for three serious, if somewhat bizarre, offences. The gun did not have live bullets but the waving and firing of it at the reporter must have caused considerable fear.

"I appreciate that there was little prospect of these offences succeeding but that is not quite the point. The public interest is at stake and you were playing for high stakes."

During mitigation before sentencing, Nina Graham, for Lambert, said he had been "foolish and naive" in his plans and said 18 months of steroid abuse had changed his personality.

"It is a naive and unsophisticated theft," she said. "It is stupid and unsophisticated and shows a staggering lack of foresight."

She said Lambert had taken bodybuilding to obsessive levels. "His steroid use escalated over the past year and a half to an almost unsupportable level," she said. "His interest turned into an obsession.

"He was taking a cocktail of steroids during all of this time. This accounts for the change in personality and inability to control aggression."

When he heard his sentence Lambert nodded and said, "Thank you."