The attorney general has blocked the publication of a book by Britain's former head of counter-terrorism, Andy Hayman, that gives the inside story of the fight against Islamist extremism.

Lady Scotland stepped in at the last minute to obtain an injunction preventing The Terrorist Hunters from going on sale today. The move came even though copies of the book had been sent two months ago to the Crown Prosecution Service, the Cabinet Office, MI5 and MI6 and the Metropolitan Police Authority.

Its author, the retired Scotland Yard assistant commissioner Andy Hayman, gives a behind-the-scenes account of the 7 July attacks, the shooting of Jean Charles de Menezes and the fight against terror.

He wrote about the murder of the Russian dissident Alexander Litvinenko and his meetings with top-level political and intelligence officials.

Thousands of copies of the 372-page book were delivered to bookshops nationwide ahead of its publication today.

An advisory notice highlighting the injunction, granted by an unnamed high court judge, was circulated to newspaper editors at 11.45 last night.

The full reasons for the injunction cannot be published for legal reasons linked to continuing criminal proceedings.

The book, however, was still available for sale on the Amazon website today, which stated: "Get it by Friday if you order in the next five hours."

The Times newspaper serialised sections of the Bantam Press book, co-written by the former BBC home affairs correspondent Margaret Gilmore.

Last week the Metropolitan police commissioner, Sir Paul Stephenson, complained that he was not given a preview of the book's contents. He told a meeting of the Metropolitan Police Authority that he was reluctant to give it more publicity.

Stephenson said members of the force's watchdog might like to consider whether senior officers should be allowed to publish such books.

"I find it surprising as commissioner that I have no right on this occasion to have access to the book before it is published. That surprises me. It is troublesome and it does not help good conduct."

A spokeswoman for Bantam Press owner Random House declined to comment.