Alex Macgillivray, the key figure responsible for Twitter's aggressively pro-free speech position, has announced he is to leave the company.

The Harvard-educated lawyer is little known outside a small crop of Silicon Valley executives and internet advocates. Known to colleagues as "A-mac", Macgillivray is described as Twitter's conscience-in-residence and credited with turning the social network into one of the fiercest defenders of user privacy in cyberspace.

He announced his departure on Friday, on Twitter and also on his own blog. He said he would be replaced by Viyaya Gadde, a member of Twitter's legal team.

"I am proud to have worked with colleagues who defend and respect the user's voice; who push freedom of expression and transparency; and who innovate and lead," he wrote. "It has been my privilege to work and fight on behalf of great companies and their users over the last decade. A privilege and a lot of work. So, I'm looking forward to engaging my various internet passions from new and different perspectives."

Macgillivray did not indicate where he might move to, but his decision to leave Twitter comes after a period of intense scrutiny over its systems for reporting abuse. It will leave the industry wondering whether Twitter may now have a less robust defence against government requests for user data, and compromise its position on free speech and privacy online.

'The free speech wing of the free speech party'

Macgillivray, who has characterised Twitter as "the free speech wing of the free speech party", joined the company from Google in September 2009. Then, mundane issues involving trademark and impersonation law were the most frequent to trouble his small team in midtown San Francisco. But as the social network has grown – it now has 200 million registered users – so have the issues it confronts.

In the past 24 months, Macgillivray has fought US attempts to gain access to the private messages of Occupy protesters and Wikileaks activists. In India, the company has faced government pressure to curb "inflammatory" tweets. In the UK, he was summoned before MPs to rebut claims that Twitter was used to fuel riots across England in summer 2011.

According to his former Harvard law school professor, Jonathan Zittrain, Macgillivray "thrives in high-pressure environments, even as – or especially because – his presence tends to ratchet down the drama."

In January 2011, Macgillivray penned an ode to freedom of expression with Biz Stone, Twitter's co-founder, under the headline: "The Tweets Must Flow." Posted against a backdrop of rebellion on the streets of Tunisia and Egypt, the 410-word article put the case for unfettered tweets.

"I think Alex is one of the few attorneys I know who routinely tries to, and often does, hack the law and use technology to make the law work for people," said Cindy Cohn, legal director of the internet rights group Electronic Frontier Foundation (EFF). "He thinks about how best to use the current law and technology to bring about a more fair and honest arrangement for Twitter, its employees and its users. That's not easy and he does it well."

Last summer, Macgillivray was faced with a crisis that went to the heart of his pledge to "let the tweets flow". The company admitted in a blogpost that it had encouraged the US broadcaster NBC, its partner during the London Olympics, to file a formal complaint about the journalist Guy Adams that led to his account being suspended.

Adams had posted the corporate email address of an NBC executive, alongside a string of pointed tweets about the company's Olympics coverage. When it emerged that Twitter had proactively monitored Adams' tweets before encouraging its partner to file a formal complaint, the social network was accused of commercially-induced censorship.

Two weeks later, Adams received a surprise telephone call from Macgillivray. "Apart from him I didn't have a single contact from anyone at that company," said Adams. "I couldn't quite work out what he wanted to achieve from the conversation except to listen to what I had to say. He was very affable – the sort of guy you could spend a very enjoyable afternoon at the baseball with – and just asked for advice on how not to screw up in the future."

He added: "Most companies grown organically over decades, but Twitter has grown exponentially in the space of a few years and frankly I think the head doesn't know what the backside is up to. Twitter finds itself slightly outpaced by the news agenda and I suppose he's trying to play catch up a lot of the time."

More recently, Twitter has avoided being dragged into controversy surrounding the National Security Agency (NSA) surveillance program, Prism. The company was not named in leaked NSA slides that claimed Google, Microsoft and othes had cooperated with Prism, although those companies have repeatedly denied all knowledge of the program.

A tech background

Like many of the technology sector's most prominent lawyers, Macgillivray got his grounding at Google. He spent eight years in Mountain View, becoming the company's primary attorney for key products including web search and Gmail – and later its controversial plans to scan millions of out-of-print library books.

Zittrain described Macgillivray as a star pupil with a "wonderfully droll" sense of humour, who was "very much aware of the power of software code, not just legal code". At Harvard, Macgillivray co-programmed software so the university could experiment with distance learning. His experimental hacking – which he did with Wendy Saltzer, the widely-respected internet lawyer and policy counsel at the World Wide Web Consortium – was not his first.

"I distinctly recall trying without success to keep up with the news on internet-related legal developments that was coming fast and furious," said a former colleague, David Kramer, a copyright lawyer at Wilson Sonsini Goodrich and Rosati (WSGR). "Alex always seemed a step ahead. Why? Because he was using a specialised news aggregation tool that he had coded himself."

Twitter's 'grave, crushing responsibility' as a gatekeeper

The challenges and opportunities Macgillivray faced at Twitter were great and many. The Adams saga underlined the dangers ahead as the company multiplies and enhances its relationships with commercial firms, like NBC or the mobile network EE. It remains to be seen whether Twitter can truly pledge to "let the tweets flow", independent of business pressures – particularly with a hotly-anticipated public flotation on the horizon.

According to Zittrain, the company's ability to instantly take down any message brings with it a "grave, even crushing" responsibility, overrun with contradictory demands. He suggested that Twitter could go further to install its values, including by structuring private direct messages so that it cannot readily scan and produce them for governments. Or, for example, separating its commercial unit from the rest of the company, in the spirit of a church-state divide.

Under new general counsel Vijaya Gadde, the company must turn those challenges into opportunities, and set a standard for best practice that others will follow.

"I couldn't be happier with her appointment," Macgillivray said, as Gadde pledged to "continue to defer users around the world". Macgillivray will bow out slowly, handing the workload to Gadde, who is well liked in the company, if less strident in her views on free speech and the rights of Twitter's users.

Despite Silicon Valley gossip pointing to a reorganisation of Twitter's legal department, a tension between Macgillivray and chief executive Dick Costolo, and a desire to leave before the administrative burden of Twitter's IPO next year, the general counsel's departure is largely amicable.

"Things at Twitter often move at the speed of thought," said Kramer. "There can be instant, worldwide attention and feedback on any action the company takes or fails to take. That puts enormous pressure on the team.

"Of course, when they get things right, as they invariably do, their decisions and the example they set echo throughout the Twitterverse and beyond."