Imran Khan is in full flow. "When people don't want to be ruled, you can't rule them," he says. "The Afghans have stood up against every invader. They lost one million men against the Soviet Union. One million!"

The cricketer-turned-politician is getting louder and louder as he explains the reasons for his opposition to the west's decade-long war in Afghanistan. "Why do they [the United States and the United Kingdom] think they are going to win?"

For Khan, whose own Pakistani family is descended from Pashtun tribesmen, the conflict is "basically a war of independence". He does not accept the arguments about counterterrorism or counter-insurgency advanced by western governments. "The Americans claim that it is because of the Haqqani [militant] groups that they cannot win in Afghanistan," he says. "Are they saying that the three, four or five thousand, maximum, fighters of the Haqqani network are the reason 140,000 Nato troops, part of the greatest military machine in the history of mankind, cannot win in Afghanistan? Because of 5,000 fighters?"

Nor is he impressed by Barack Obama's decision to set a timetable for full withdrawal of US troops from Afghanistan. "What has he achieved? And what are they doing right now? There have been more night raids this year than ever before. If even Hamid Karzai [the Afghan president] is complaining about night raids, there has got to be something wrong, because they kill innocent people. And they strengthen the Taliban. It's totally counterproductive."

He shakes his head wearily. "Obama's biggest blunder is that he fell in the trap of generals and generals always want more troops and more action."

In January 2009, after Obama was elected to the White House, Khan wrote an open letter to him in which he pointed out that "the roots of terror and violence lie in politics - and so does the solution". "I told him, 'Do not own Bush's war [in Afghanistan].' I said: 'You're not going to win this.'"

Khan and I meet at the home of his former mother-in-law, Lady Annabel Goldsmith. She is trying to quieten three barking dogs as I arrive at Ormeley Lodge, the Goldsmith family's 18th-century Grade II-listed Queen Anne house near Richmond Park in Ham, where Khan stays on visits to London, in an upstairs apartment on the edge of the grounds.

Khan and Jemima Goldsmith were married in 1995 and divorced in 2004, when Jemima returned from Pakistan to London with their two sons. Khan writes movingly in his latest book, Pakistan: a Personal History, of how difficult it was to "make our cross-cultural marriage succeed" and accuses "external forces" of attempting "to sabotage our family life". After he entered Pakistani politics, Jemima was targeted by his political enemies and, he writes, "the government-sponsored media". She was attacked for her appearance, her wealth and her Jewish background. "It wasn't the people, it was the political class," he says now. "The people actually loved her."

However, he notes: "She went through hell, in the sense that someone who is not used to this becomes a Muslim, first she gets a spate of negative articles here in the UK . . . And then she comes to Pakistan and, though they were fine at first, the moment I enter politics they [the Pakistani establishment] go for her, accusing her of being part of a 'Jewish lobby'. I think it was hard for her, very tough for a young girl."

Jemima was 21 when they married - 21 years younger than her husband. Khan came to regret his decision to move her to Pakistan. "I felt I might have been irresponsible. Just because I could deal with the attacks, that didn't mean that she could, too."

Perhaps he should have considered moving to London to save the marriage; but Khan says there was "never a choice" about where they would be based. "When I married Jemima she knew that I was going to live in Pakistan. I had made it clear that [Pakistan] is where my life was. When it ended, there was this feeling that I'd given it my best shot."

He describes his separation from his sons, who live in England and whom he sees only in the school holidays, as the great "void" in his life. "My children gave me my greatest happiness and fatherhood was the thing I loved most, and so I was deprived of that." He turns to faith for solace. "It is the will of Allah. As the Prophet said, 'Don't fight destiny because destiny is God.' There is an [understanding] that, once you've tried your best, you accept things. At least I have more access to my children than in most cases of divorce."

How has he managed to keep such good relations with Jemima and her family? All he will say is that it is "very important for the sake of the children that you have a good relationship".

Perched on the edge of a yellow couch, Khan is wearing a tatty red jumper and dark blue jeans, and he has a cold. He is 58 but has the look of someone a decade younger, still physically impressive, with a full head of tousled black hair. He speaks in a deep and commanding voice, and intersperses answers to my questions with verses from the Quran and lines of Urdu poetry.

He begins our conversation by explaining that he wrote Pakistan: a Personal History for his two sons, Sulaiman, aged 14, and Kasim, 12. He felt, as a Pakistani, that he "should explain to them what is happening there [in Pakistan]. There is total confusion. The majority of the population is under 30. The young people have no idea what is happening; they are confused about Islam, confused about the west, confused about terrorism."

Khan, once a playboy on the London social scene, underwent a spiritual and religious reawakening in the late 1980s after a chance meeting at a dinner party with a Sufi mystic named Hazrat Mian Bashir. These days, he refuses to define his faith according to the usual criteria of Sunni/Shia, conservative/liberal, Islamist/moderate. "I am a follower of Iqbal," he says bluntly, referring to the legendary Muslim poet, philosopher and intellectual of the Indian subcontinent who died in 1938. "He is my role model. The man was a genius. He had so many facets to him." Khan becomes animated. "Iqbal is a notion. Iqbal understood the dynamism of Islam as a religion and as spirituality."

The final chapter of his book is devoted to the lessons that modern Pakistan can learn from the great man. Khan describes him as "the undaunted thinker who urged the oppressed [Muslim] masses to revolt against all forms of totalitarianism - religious, political, cultural, intellectual, economic, or any other".

However, he is not opposed to the teaching of some of the more austere and literalist brands of Islam, such as Salafism and Wahhabism. His only criterion is that they should not "breed hatred of other human beings, which is anti-Islamic". He accepts that the Pakistani government needs to "clamp down" on the more militant madrasas but argues: "In my opinion, no government which is perceived as a stooge of the Americans can do that."

Where some in the west have demanded an "Islamic Reformation", Khan disagrees, distinguishing between the religion and its adherents. "No, not Islam - Muslims! Muslims need to reform themselves," he says. "You need a proper intellectual debate to go on in the Muslim world."

What's stopping it from happening?

“It doesn't happen any more because of the war on terror: it has destroyed all debate in our country. You don't want to get caught on the 'other' side."

In January, Salman Taseer, governor of Punjab Province, in Pakistan, was murdered by his own bodyguard for daring to campaign against the country's blasphemy law. Does Khan fear for his own safety? "I've gone past that," he says breezily. "That's what faith does. There is a verse in the Quran: 'Those who have faith, Allah removes their fears.' So I actually have no fears in life. If I die, if I go" - he pauses - "well, I am trying my best."

Khan says his Muslim faith teaches him to accept death, rather than fight it or try to postpone it. He could, however, take precautions, couldn't he? "Well, there is a limit to precautions, Benazir [Bhutto] took precautions . . ." His voice trails off. Writing in his book about Bhutto's return after eight years of exile from Dubai to Pakistan in October 2007, Khan describes the former Pakistani prime minister as "a dead woman walking . . . a target to the militants on one side . . . and on the other side a target to politicians threatened by her, scared they would lose power". She was assassinated the following December.

Khan founded his own political party, Teh­reek-e-Insaf ("Movement for Justice"), in 1996, and served as a member of parliament between 2002 and 2008. He plans to contest the next parliamentary and presidential elections in 2013. His mission, he says, is to combat corruption in Pakistan. He will not, however, be drawn on the question of his politics. Is he a conservative? A social democrat? A liberal? He shakes his head. "These are just western terms for western parties proposing western solutions. I am completely rooted in Pakistan. I want a welfare state, the rule of law and a sovereign Pakistan - whatever it takes to fulfil these three goals."

Critics describe him as an opportun­ist, willing to appease Pakistan's religious parties in order to win votes and gain popular support. In the words of one newspaper profile of Khan in 2005: "[H]e preaches democracy one day but gives a vote to reactionary mullahs the next."

He looks annoyed. "No, no, hold on. What they don't understand is that those were votes against the government. I was against the government. And the mullahs were against the government. The problem [in the west] is that you look upon Muslim societies from a perspective of: 'Either you're with the fundamentalists or with the liberals.'" For him, the only political battle that counts is against the "ruling mafia" in the two major parties, the Pakistan Peoples Party and the Pakistan Muslim League. The mullahs' stance is, therefore, irrelevant.

He wasn't always so opposed to the ruling mafia, however, throwing his support behind Pervez Musharraf in the 2002 referendum that allowed the general to stay on as president of Pakistan for another five years. Khan is understandably defensive when I raise the matter.

“[Musharraf] came in and he promised us a real democracy instead of sham democracy, so we backed him, but where I made a mistake was backing him in the referendum, which was against the constitution. And I made the mistake because we were so worried about Nawaz [Sharif] and Benazir coming back [to power] that we actually thought that this man [Mush­arraf] was sincere. So we were fooled, yes. We made a mistake."

In subsequent years, he became an outspoken opponent of Musharraf, denouncing his pro-western and pro-war policies. Yet did the general have any other option other than to join with the Americans in 2001? Richard Armitage, the then US deputy secretary of state, is alleged to have threatened to bomb Pakistan "back to the Stone Age" unless it signed up to the fight against al-Qaeda and the Taliban.

Khan is not sympathetic to this point of view. "This is where a leader comes in," he says, his voice rising. "You have to be able to take pressure, otherwise you're not a leader. Just because someone threatens you . . . You can fight back and say, 'Why should we do this?' If Turkey could stop the US troops going through Turkey into Iraq [in 2003], how come we destroyed our country and violated our own people's rights for just $20bn [in US aid]?"

I wonder whether his approach to the question of Islamist terrorism and violent extremism is too simplistic. Wasn't Pakistan engulfed by sectarian violence and awash with militant groups even before the 11 September 2001 attacks and the launch of the US-led war on terror? "Let's just put it in perspective," he counters. "If you look at the entire history of suicide attacks in Pakistan, there was just a handful before 2001. There have been hundreds since. You don't even report a suicide bombing any more; it gets four lines now [in the press]. How can you compare that era with this one?"

He concedes that Pakistan's militant groups were nurtured and sponsored by the Pakistani army - specifically the notorious Directorate for Inter-Services Intelligence (ISI). But does he also believe that the ISI was protecting Osama Bin Laden, who was discovered to be living less than two miles from a prestigious military academy in Pakistan? "God alone knows," he sighs. "Here was the Pakistani army being attacked, soldiers dying - why would they nurture this man who was considered the main brains behind the violence? There is a contradiction in this. So why would they do it?" (In his book, however, he notes the former ISI chief Lieutenant General Ziauddin Butt's claim that Musharraf "kept Osama in the safe house in Abbottabad to milk the US for dollars".)

Khan takes a bold approach to the wider challenge posed by the wavering honesty and loyalty of the Pakistani military. "No more aid," he declares, leaning forward in his chair. "This is the answer. What do we learn from being a front-line state? First we created the jihadis and then we killed them for dollars.

The common thing was dollars - so no more dollars, no more aid." (It is believed that his position irks senior ministers and civil servants in Britain's Department for International Development.)

Khan argues that it is intellectually lazy to describe widespread Pakistani protests against the so-called war on terror, and the associated burning of flags and effigies on the streets of Islamabad and Karachi, as "anti-Americanism". "Why don't people understand that the Pakistanis hate US policies, not the country? In the UK, when you protest, you're not accused of hating your country. The two million people who came out on to the streets to protest against the Iraq war weren't anti-British. They were anti the policy [of invading Iraq]."

He is equally keen to defend himself against the charge of anti-Americanism. "I know the west. I understand the west. I have family here in the west. I know that it is a question of interest groups driving the policy, it's not the people; ordinary Americans are as much victims of the policy as we are. The military-industrial complex, which I talk about [in the book], is doing as much harm to them as to us."

In May, a poll by YouGov found that two-thirds of Pakistanis did not believe Osama Bin Laden had been killed by US special forces in Abbottabad. "But why do you blame them?" Khan asks. "They're lied to all the time by their leaders. If a society is used to listening to lies all the time, they try to think, what's behind it, what's the truth, and then everything becomes a conspiracy."

Khan the politician has faith in his fellow countrymen. He points to two recent polls - by the Pew Research Centre and YouGov - which show Tehreek-e-Insaf enjoying approval ratings of between 60 and 70 per cent. But an official at the US embassy in Islamabad disputes those results and tells me that the embassy's internal polling puts Khan's party much lower - at between 10 and 20 per cent. Nonetheless, 100,000 supporters flocked to a Khan-led rally in Lahore on 30 October.

In person, Khan seems naive, innocent, even. I remind him that his party has been nothing but marginal since it was founded in 1996. At the first general election it contested, in 1997, Tehreek-e-Insaf won no seats even though Khan stood in seven separate constituencies. In 2002, the party won 0.8 per cent of the popular vote and secured the election of just one MP - Khan - out of 272 chosen. Then, in 2008, Khan and his party boycotted the elections over Musharraf's decision to place the chief justice under house arrest, leaving them without any parliamentary representation whatsoever.

A cynic would say that Pakistan's corrupt, power-hungry political and military elite will never allow Khan to win. Wouldn't they just rig the result, as in countless previous contests? Khan shakes his head. "For the first time, we have an independent supreme court that can supervise the elections."

He continues: "Being prime minister for me holds no attraction. Being someone who is a catalyst for change, bringing in a big revolution in Pakistan and changing the way the country is going - that holds an attraction for me." He looks out of the window and into the far distance. "I would only want the premiership if I can then use it to bring about a socio-economic revolution in Pakistan."

So does he think he'll win next time? "I have no doubt," he says, with his usual confidence. "It is clear in my mind that there is only one party that is going to win."

Imran Khan's "Pakistan: a Personal History" is published by Bantam Press (£20)

Mehdi Hasan is the New Statesman's senior editor (politics)