Somini Sengupta / New York Times News Service

SAN FRANCISCO — Alexander Macgillivray, Twitter’s chief lawyer, says that fighting for free speech is more than a good idea. He thinks it is a competitive advantage for his company.

That conviction explains why he spends so much of Twitter’s time and money going toe to toe with officers and apparatchiks both here and abroad. Last week, his legal team was fighting a court order to extract an Occupy Wall Street protester’s Twitter posts. The week before, the team wrestled with Indian government officials seeking to take down missives they considered inflammatory. Last year, Macgillivray challenged the Justice Department in its hunt for WikiLeaks supporters who used Twitter to communicate.

“We value the reputation we have for defending and respecting the user’s voice,” Macgillivray said in an interview here at Twitter headquarters. “We think it’s important to our company and the way users think about whether to use Twitter, as compared to other services.”

It doesn’t always work. And it sometimes collides awkwardly with another imperative Twitter faces: to turn its fire hose of public opinion into a profitable business. That imperative will become far more acute if the company goes public, and Twitter confronts pressures to make money fast and play nice with the governments of countries in which it operates; most Twitter users live outside the United States and the company is opening offices overseas.

That transformation makes his job all the more delicate. At a time when Internet companies control so much of what we can say and do online, can Twitter stand up for privacy, free expression and profitability all at the same time?

“They are going to have to monetize the data that they have and they can’t rock the boat, maybe,” said Ryan Calo, a law professor at the University of Washington. “I don’t predict Twitter is going to lose its way, but it’s a moment to watch.”

Jonathan Zittrain, one of his former professors at Harvard Law School, called it both a challenge and opportunity for Macgillivray, widely known as @amac, his handle on Twitter, and one that could influence the Internet industry at large.

“If @amac can help find a path through it, it may serve as a model for corporate responsibility for an Internet where more and more code and content is governed by corporate gatekeepers,” Zittrain said via email. He added that the challenge for Macgillivray “is not only to pioneer a wise way through this thicket, but to implement it as Twitter’s use continues to explode. It’s complex maintenance on a jet engine while the plane is in flight.”

Twitter hit some turbulence this summer when it seemed to forget its principles. The company briefly suspended a British journalist, Guy Adams, who had used his Twitter feed to repeatedly criticize the handling of Olympics coverage by NBC, a corporate partner of Twitter.

This kerfuffle reveals something of the identity crisis that Twitter faces. It is both a gadfly’s bullhorn and a valuable stream of business intelligence. And with an $8 billion valuation, its business strategy is being closely watched. Twitter has lately stepped up ways to draw advertising revenue while Wall Street waits for it to go public.

Macgillivray insists that like a traditional media company that distributes information, Twitter, too, draws a hard line between the moneymaking side of the company and the content its users post. He calls it a church-state divide.

“You don’t want business interests affecting judgment about content,” he argued. “That is against corporate interests. It’s against the trust your users have in your service.”

Other technology and communications companies have repeatedly stumbled on issues of free speech and privacy. Yahoo supplied information that helped Chinese authorities in 2005 convict a journalist. Google in 2010 withdrew from China after hackers from that country stole proprietary computer code and hacked into Gmail accounts of human rights activists. Google and Twitter both issue annual reports that tally information requests from individual countries; Facebook, that other trove of personal data, does not, and insists on the use of real names, which, its critics say, can endanger dissidents and others with unpopular opinions.