Tony Blair has said it was wrong to cold-shoulder Hamas and that the group should instead have been “pulled into the dialogue”.

The stunning admission by the former prime minister, who become Middle East Peace Envoy after leaving Downing Street, came in an interview for a book about Gaza, to be published later this month.

In ‘Gaza: Preparing for Dawn,’ Blair says: “In retrospect I think we should have, right at the very beginning, tried to pull [Hamas] into a dialogue and shifted their positions. I think that’s where I would be in retrospect.”

He added: “Obviously it was very difficult, the Israelis were very opposed to it. But you know we could have probably worked out a way whereby we did – which in fact we ended up doing anyway, informally.”

The “informal” contacts he describes are widely believed to be between Britain’s Secret Intelligence Service (MI6) and Hamas in efforts to free BBC reporter Alan Johnston, who was kidnapped by a fundamentalist group. Hamas pressure helped ensure his release.

Since leaving his role as representative of the Middle East Quartet, which comprises the European Union, United States, United Nations and Russia, Blair has met Hamas political leader Khaled Meshaal and his successor Ismail Haniyeh six times, in part to explore the possibilities for a settlement.

Blair’s decision to ostracise Hamas in 2006, after Hamas had won an election in the Gaza Strip, which international monitors said was “free and fair”.

George W. Bush’s White House had earlier refused to recognise Hamas until it recognised Israel, renounced violence and agreed to abide by agreements between Israel and rival Palestinian group Fatah.

Blair’s former chief of staff at Downing Street, Jonathan Powell, interviewed for the same book, agreed that it was “a terrible mistake” to negotiate with Fatah alone, because “you have to make a concession to Fatah, then you have to make a new concession to Hamas afterwards. You want to have one negotiation, not two”.

Documents from the Department of International Development from 2006, released under a Freedom of Information request, show that British civil servants warned politicians against ruling out dealings with Hamas, pointing out that Hamas and Israel worked together in municipal areas.

Instead of shunning Hamas, mandarins suggested that “ultimately Hamas’s participation in the realities of political responsibility might bring about Hamas’s transformation to a political rather than terrorist organisation”.

Last week Hamas and Fatah announced that they had agreed a reconciliation deal between them.