'Rather than Hamas being a problem, we should strive to make them part of the solution.' These words come from a man whom no one could accuse of being soft on terrorism. Efraim Halevy ran the Israeli external security service, better known as the Mossad, from 1998 to 2003. Before that, he was the secret envoy of five Israeli prime ministers. Now Mr Halevy is calling for new thinking on Hamas, al-Qaeda, and the future of the 'war on terrorism'. When we met, the former head of the Mossad was sipping a herbal tea in an elegant London hotel. He looked more like an unassuming civil servant than a man who mastered one of the world's most feared, and admired, secret services. No doubt an eye-catching appearance is a disadvantage in the secret agent's trade. Although Mr Halevy was affable and polite, he rarely made eye contact, staring off into the middle distance throughout our hour-long discussion. 'Unlike the government, I don't believe that Hamas needs to declare that it recognises Israel,' he said. 'It needs to make major changes to its policies, which have not yet come about. But Hamas should be judged by its actions rather than its words.' What specific actions does he think Hamas needs to take? 'They should act in a way that is commensurate with the behaviour of a sovereign state, accepting the international norms of behaviour towards other states,' he said. 'Now that they are the government, they need to prevent the other militias - the Palestinian Islamic Jihad, the Popular Front for the Liberation of Palestine, and the Al-Aqsa Martyrs Brigade - from carrying out attacks. This is the responsibility of a sovereign government and if Hamas does not shoulder it, its sovereignty need not be respected.' So far, there has been no sign that Hamas is willing to take on the difficult and domestically controversial job of reining in other Palestinian militias. But even if Hamas sees other militias as a challenge to its own authority, would it be able to stop their activities? 'If Hamas is willing to take these groups on, it would be in a better position to do so than [its predecessor] Fatah was,' Mr Halevy said. 'But if it fails to do this, Israel will respond in kind. Then Hamas would be unable to exercise authority as a government. Its domestic agenda would fall apart. The Palestinian Authority could collapse.' Mr Halevy is under no illusions about Hamas. But in discussing his new book, Man in the Shadows, he picks out two key lessons he learned as head of the Mossad. First: 'We must always think the unthinkable - for the unthinkable usually happens.' Second: 'Very often in history, the devils of yesterday become the angels of today - and vice versa.' To illustrate this point, his book begins at the end of the Iran-Iraq war, when Saddam Hussein was a hero to the west, and ends in 2006, with Hussein overthrown and facing trial. The Taleban underwent a similar transformation from Washington's anti-communist darlings to its fundamentalist foes. Meanwhile, Libya's Muammar Gaddafi has become a friend of the west, with British Prime Minister Tony Blair visiting his tent for tea. So in a world of shifting alliances, Mr Halevy thinks that Hamas might become 'not angels, but at least reasonable people'. 'Hamas could be a very effective force opposing al-Qaeda,' he said. 'The scourge of Islamic terror would be easier to defeat if Hamas was closer to our side than the other side.' Although Hamas and al-Qaeda both claim Islamic legitimacy for their attacks on civilians, there are big differences in their aims - a point often ignored by those who lump them all together as radicals or extremists. Essentially, Mr Halevy argued: 'The west has no possibility of a truce with al-Qaeda. The only solution is total destruction.' However, he said that a truce may be possible with Hamas. Hamas Prime Minister Ismail Haniyeh has said the group could offer a 10- to 15-year temporary truce known as a hudna. Critics fear Hamas could use this time to organise and arm itself for an even bigger onslaught. Mr Halevy said this opportunity could be constructive if managed carefully: 'I don't see a terrorist waking up in 2026 without having fired a shot for 20 years, looking at his wife and kids, and deciding it's time to go back to war.' So why is Hamas so different from al-Qaeda? 'Hamas is a territorial organisation, wedded to territory,' he said. 'It is primarily motivated by the desire for a Palestinian state, not the desire to destabilise countries and societies around the world. But al-Qaeda is not wedded to any territory; its aims are universal.' Hamas sought to be part of the international system of states, while al-Qaeda sought only to destroy it. And Hamas had much more to lose. Now more than ever, Hamas had developed political and social interests, including educational activities and charity work. More broadly, Mr Halevy pointed out, Hamas had ties to the broader movement of the Muslim Brotherhood. And it was the first offshoot of the brotherhood to take on the task of government. This brought a weight of responsibility upon Hamas. If Hamas failed, Mr Halevy argued, the entire movement would be seen to have failed. And, in his view: 'Hamas knows it cannot succeed if Israel chooses to destroy it.' As Hamas consolidated its power and developed more entrenched political instincts, 'Hamas will not wish al-Qaeda to turn the Palestinian areas into an Iraq-style situation. It could come to see al-Qaeda as a threat to itself.' This outcome is by no means certain. But in Mr Halevy's view it is well worth pursuing because, confident as he is that the west must keep fighting what he calls 'world war three' with al-Qaeda, the former Mossad chief thinks that ultimately al-Qaeda can only be defeated from within the Islamic world. For Mr Halevy, who was in charge of the Mossad on September 11, al-Qaeda is the most serious threat that Israel and the west face. By contrast, while he thinks Iran is a serious threat, 'the world has the means to prevent Iran from developing these capabilities. The fear of diplomatic action and economic action will be very important.' Is there any sign these are working? Mr Halevy is reluctant to make any hawkish statements. 'An attack would be a last resort,' he said. 'We're not there yet. The less said the better.' He held one hand up in a silencing gesture. What will be the priorities for Israel's new government? 'The election result was sobering from any point of view, as [winning party] Kadima did not do as well as it had hoped,' Mr Halevy said. No Israeli party has ever won an outright majority in Israel's Knesset (parliament); the country's proportional representation system means coalition-building is a permanent fact of political life. But this year, the vote was even more split than usual, and Kadima will face serious challenges juggling the interests of multiple coalition partners with many ideological differences. 'With the tough problems Israel faces, we need more attention to building an internal consensus, not more confrontation within the country. The disengagement has opened wounds much more serious than we admit.' Does he support the proposals for further unilateral moves, whereby Israel would try to set its final borders? Mr Halevy is strongly opposed. 'In the Middle East, you should never give something for nothing,' he said. 'In the eyes of the Palestinians, the pullout from Gaza was a direct result of the armed struggle and a clear victory for Hamas.' Indeed, Hamas' successful election campaign made much of the group's role in securing the pullout. As a retired official, Mr Halevy can make critical and controversial contributions to political debate. Will elected officials, with most of their career still ahead of them, dare to talk of a possible truce with Hamas, a group that Israel has said it would never deal with? 'It may be premature right now,' he said. 'It will take them a little time. But one thing [former Israeli prime minister Ariel] Sharon did was break taboos. In 2003, I said that we should leave Gaza. At that time, Sharon said absolutely not.' Only two years later, leaving Gaza became Mr Sharon's pet project, for which he tore apart the Likud Party that he had spent his life building. After his years as an insider, witnessing dramatic changes of course, Mr Halevy has good reason to believe the unthinkable might happen - yet again.