On 25 July 2010, two unrelated events took place in the space of 60 minutes that would change Benedict Cumberbatch's life for ever. At 9pm that evening, the BBC broadcast episode one of Sherlock. At 10pm, the Guardian, the New York Times and Der Spiegel published the first instalment of the Afghan war logs, courtesy of WikiLeaks.

Cumberbatch wasn't aware of the second event that night, because by then his name was trending on Twitter and his phone was going berserk. The actor was watching himself soar from respectable levels of critical acclaim into the stratosphere; Afghan war logs were the last thing on his mind. He'd never even heard of WikiLeaks or Julian Assange, and wouldn't discover what they would hold for him personally until more than two years later when his agent rang while he was at a friend's birthday party.

"I remember it really clearly," he says. "I had to go into the stairwell to try to get better reception. I heard them say, 'These people are really interested in offering you this part playing Julian Assange.' There was a TV series idea kicking around at the time, and I thought that was it, so I said, 'Great, I didn't realise that series was going ahead.' They said, 'No, it's DreamWorks.' 'DreamWorks are doing a film about Julian Assange!?' 'Yeah, and they want you to do it.'"

By then Cumberbatch was on the sort of roll every actor dreams of. Before Sherlock, he'd been a slightly odd-looking character actor accustomed, he liked to joke, to "big parts in small films, and small parts in big films", having played Stephen Hawking, Van Gogh and William Pitt, as well as supporting roles in Atonement and The Other Boleyn Girl. His modern-day Sherlock Holmes, however, was a revelation: cold-eyed, impatient, fast-talking, like a human iPad with a hint of Asperger's thrown in. Steven Spielberg declared it the greatest on-screen Holmes ever. Since that first series, watched by nearly 10 million in Britain alone, Cumberbatch had starred in War Horse, Star Trek Into Darkness and Tinker Tailor Soldier Spy, won an Olivier for his performances in Danny Boyle's Frankenstein at the National, and been voted the sexiest man alive. But playing Assange is his biggest role yet.

In January, he flew out to Iceland to begin filming. The man he was to play had by then been under police guard in the Ecuadorian embassy for more than six months, and had ignored all requests by the actor to meet. The very day before shooting began, just as he was having the final tests for his wig and makeup, Cumberbatch received a 10-page email urging him not to make the film. It was from Assange.

"It was a very considered, thorough, charming and intelligent account of why he thought it was morally wrong for me to be part of something he thought was going to be damaging in real terms, not just to perceptions but to the reality of the outcome for himself. He characterised himself as a political refugee, and with [Bradley] Manning awaiting trial, and other supporters of WikiLeaks who have been detained or might be awaiting detention, and the organisation itself – all of that being under threat if I took part in this film."

Did he wobble? "Of course. The fact that it was coming from the man himself, the day before we started filming? Of course I would hear and feel the protests of the man I was about to pretend to be. I'm a human being."

Had Assange persuaded him to pull out, Cumberbatch would not now be looking at a likely Oscar nomination. I watched the film directly before our interview, and his portrayal is so convincing that at the end I felt a moment of genuine confusion and thought I was about to meet Assange himself.

As Julian Assange in The Fifth Estate, with Daniel Brühl as Daniel Domscheit-Berg. Photograph: AP

In real life, Cumberbatch looks nothing like the WikiLeaks founder. He is also unlike any actor I've come across. We first met last summer, when he had just finished making Star Trek in Hollywood, and was brimming with the bouncy charm common to men enjoying a sudden inflation in their sexual currency. The vertiginous cheekbones, snub nose and slanted green eyes have had him famously likened to an otter, but Sherlock had transformed him into a pin-up, and he cheerfully admitted to making the most of it. When we meet again at the Toronto film festival, where The Fifth Estate has just premiered, he is surrounded by a circus of publicists, people with clipboards, stylists and whatnot, but the easy, unguarded friendliness has somehow survived. He is not the only successful actor to hold on to his good nature in the face of fame, but most are less interesting than the characters they play. You get an idea of why Cumberbatch isn't from his description of what he wrote in response to Assange's email: "I don't want to go into any great detail, but it took me four hours and the central thrust was: this is not documentary, this is not a legally admissible piece of evidence in a court of law, it's not going to alter perception in a way that is actually politically going to damage you at all. People who will come to see this film will be savvy enough to see it as what it is; it's a starting point, that should both provoke and entertain. It will be a talking point, but your life, your private life, your persona, is fatefully intertwined with your mission – it cannot not be now. And to be honest, I think the sort of general perspective on you is still echoing from the kind of character assassinations that began way back when, with the initial leaks, and that is now heightened by the accusations of sexual misconduct in Sweden, and so you're known as this white-haired Australian weirdo wanted for rape in Sweden who's holed up behind Harrods in some embassy. So the misinformation about you is already there.

"I said listen, this film is going to explore what you achieved, what brought you to the world's attention, in a way that I think is nothing but positive. I admit to doing work because I'm a vain actor. I want to be able to say, yeah, I'm playing a lead in a film. That's a huge career move for me. Yet I'm not acting in a moral vacuum. I have considered this, and whatever happens, I want to give as much complexity and understanding of you as I can."

If I were Assange, I'd almost certainly have thought, well, he would say that, wouldn't he? But the intellectual engagement must have been unmistakable and, though Assange may not have believed him, Cumberbatch was telling the truth.

The film begins in 2008, and follows the WikiLeaks founder's ascent from underground hacktivist to international terrorist, in the eyes of Washington, or swashbuckling cyberhero to his admirers. It focuses on the intensely complex and ultimately soured friendship between Assange and his righthand man, a German hacker called Daniel Domscheit-Berg, as well as his wary and ultimately fractured relationship with the Guardian. But it ends before the allegations of rape in Sweden saw him arrested, jailed and held under house arrest for a year, and before his flight to asylum and indefinite captivity in Ecuador's London embassy.

I interviewed Assange in the embassy last year, and there are moments in the film when it's hard to believe it isn't him on screen. Cumberbatch's performance doesn't so much evoke as inhabit his character, and the accuracy of the voice, physicality and mannerisms is uncanny. He captures Assange's extraordinary capacity to charm and beguile, to intoxicate and manipulate, while offering glimpses of his isolation.

When Cumberbatch first read the script, he worried that it cast Assange as some kind of cartoon baddie. "I think I may get my head bitten off by Disney for saying so, but everyone agreed with that." He immersed himself in research, reading endlessly and interviewing people who knew Assange, and gradually the script evolved into a more nuanced portrayal. His performance draws heavily on his research into Assange's childhood. "I know it's a Freudian cliche to go, 'Oh well, when I was a kid…', but, to be honest, it's so profoundly true with Julian. To have been a child in a single-mother relationship, being pursued around the country by an abusive stepfather who was part of a cult – to be taken out of any context where he could discover who he was in relation to other people – well, to then become a teenage hacktivist, and evolve into a cyber-journalist, to me makes perfect sense. And he's still a runaway today. I find that profoundly moving.

"He kept isolating himself. Every bridge he built, he burnt. And I understood why at times, because he is on a trajectory that's different from other people. And, because of that, he can't form those human relationships that other organisations have. And that is tragic."

Those who know Assange have often speculated that he might be on the autistic spectrum. Cumberbatch says he has no idea if that is true, but seems to suspect not. "The bridge-burning thing could just be circumstantial nurturing from what happened to him as a kid. How do you build trust when that's constantly been taken away from you?" He doesn't buy the theory that he's just a vain egotist, either. "Because you can counter that with, no, he's basically putting himself out on a limb for something he believes in, a rigid ideology, and that's uncompromising. That behaviour seems to be solipsistic, but that's because of what he's holding on to."

It's an ideology Cumberbatch subscribes to only up to a point. He opposed the war in Iraq, and marched with a million others against it in 2003. "And it was such an amazing day. Though kind of dominated," and he starts to giggle, "by the protester with the placard saying 'The Only Bush I Trust Is My Own', which always makes me laugh. But that was the only thing that does make me laugh, thinking back to that day. There was just the despondency of realising that it meant nothing." When he read the WikiLeaks reports in the Guardian in 2010, about what western troops were up to, he'd been horrified. "Death squads and civilian casualties and underarmed soldiers and strategic mishaps and the brutalisation of soldiers and the terrorising of civilians: the worst fears we had about that war just came flooding through, and I thought it was extraordinary."

But before Assange and his followers get too excited, Cumberbatch turns out to be decidedly ambivalent about what WikiLeaks and other cyber-whistleblowers such as Edward Snowden are up to. He is alarmed by the revelations of mass surveillance by the NSA and GCHQ, and doesn't like the idea of anyone reading his private emails – "It's none of your business" – but then adds, "Oh, but you might have stopped me from being killed on a tube I took last Wednesday. If they are saving lives, how can we say that's less important than civil liberties? You don't have any civil liberties if you're dead. Isn't it hypocritical to say, we should know everything about you as a government, but the government can't know anything about us?" Assange argues for total transparency for powerful institutions, and total privacy for individuals. "But if you are a private individual who's packing semtex to kill people and destroy what we know as democracy for political purposes, then you're more than just a private individual."

As for Bradley, now Chelsea, Manning, the young US army officer who leaked hundreds of thousands of war logs, diplomatic cables and other US state secrets to Assange and has just been sentenced to 35 years, Cumberbatch is sympathetic on a human level. "But he broke a law. He knew what he was doing." Manning has applied for a presidential pardon, but Cumberbatch can't see why Obama should grant it. "He did what he did out of a conviction that an alarm bell needed to be sounded. But his superiors might have been right to say to him, it's not your position to be worried about it within the hierarchy of the military organisation, which is why he had to be sentenced. He took an oath, and he broke that oath."

With Martin Freeman in Sherlock: 'He’s hard work, but I love him.’ Photograph: BBC

This sounds to me like the former public schoolboy in Cumberbatch speaking, though I hesitate to say so, because he is so weary of the peculiarly British critique that he is too posh to deserve success. His parents are both jobbing British actors, Tim Carlton (Minder, Bergerac) and Wanda Ventham (Only Fools And Horses), who scraped together just enough money to send their only son to Harrow, in the misguided hope that it would launch him into a more dependable career than acting. He had great fun at Harrow, but headed straight from there to drama school in Manchester, and is now stuck with a toff tag that the tabloids have made much of. When I ask him to name the most maddening misconception about him, he mutters, "I think the Daily Mail Online has covered just about every one of them."

The celebrity press are also having lots of fun with his bachelor status, managing to publish a new photograph and rumour practically every week featuring a new "mystery beauty". For 12 years his girlfriend was the actor Olivia Poulet, whom he met at drama school, and who played the Tory spin doctor Emma Messinger in The Thick Of It. The relationship ended in 2011, and Cumberbatch always gets quite cross at the suggestion that he dumped her after hitting the big time with Sherlock. He has often talked about wanting to become a father, but at 37 there is no sign of that yet.

Actually, it's entirely possible that he hasn't talked about anything of the sort. Cumberbatch has reached that level of fame where even the most throwaway remark is parsed for hidden meaning and rebroadcast to the world as a statement of the utmost importance. A recent one was a report that he had a crush on Matt Damon and was desperate for an introduction.

"I have to explain this whole thing about Matt Damon," he laughs. "I'm a big fan of his, I think he's great. I mention this in a phone interview, and the woman down the other end of the line goes," and he adopts a silly, high-pitched American accent, "'Really? Do you really like him? Really? Why?' I was like, 'Why? Well, um, because he's a really talented actor, he's done lots of great things in his life, I think he's great. It'd be great to meet him.' 'You wanna meet him?' 'Er, well, yeah, I mean, of course it would be great to meet him and hang out.' 'Well, we could facilitate it!' 'Oh, OK. Great. Do pass on that I'm a huge fan. It would be great to see him.'" He pauses to roll his eyes. "Next day: 'Benedict Cumberband's Bromance With Matt Damon!' You know," he laughs, "it's all that shit." Does it drive him mad? "Well, sometimes. But mostly amused, really. You can't get too tied up with it."

He doesn't think he's an infinitely better actor now than he was before Sherlock, when he didn't have to deal with this sort of crazed attention. "No, I think I've just been asked to do more. And the more you do, the more people trust that you can do." But it's a nuisance that's unlikely to go away soon: this year he'll appear in two more big films, August: Osage County and 12 Years A Slave, and he has also recently finished filming series three of Sherlock.

"I felt very sentimental on the last day of shooting, thinking, 'Oh, I've got to say goodbye to him again.' He's fucking hard work, always has been, but I love him, and I got sad that I wasn't going to see him again for a while." He won't reveal much about the new series, beyond a coy, "Well, there's a reunion that doesn't necessarily go to plan. And there's a bonding experience that throws Sherlock and Watson back together in a very firm way. And there's a new union as well, in the shape of a marriage, which Sherlock takes part in, so we see that."

Before he heads off to rejoin rehearsals for another film, The Imitation Game, in which he plays another real-life character, Alan Turing, I begin to ask one last question, but he's guessed it before I finish. Does he ever think, I say, that right at this very moment…

"He's still there? Yeah. I think about that a lot." Assange remains a fugitive in the Ecuadorian embassy, and Cumberbatch has often walked right by the window, wondering if he will ever get out.

"How is it going to play out? I don't know. It's conceivable that he'll still be there in 20 years' time, isn't it?"

• The Fifth Estate is released in the UK on 11 October. An updated version of WikiLeaks: Inside Julian Assange's War On Secrecy can be preordered for £5.99 (RRP £7.99) at guardianbookshop.co.uk.

• The Fifth Estate: first look review

• News: Benedict Cumberbatch launches defence of Julian Assange

• The subheading on this article was amended on 16 September 2013 because it did not adequately reflect a nuanced interview.