Microsoft Corp. is buying Yammer, a social networking service for businesses, for $1.2 billion, the companies announced Monday.

Attorneys from Orrick, Herrington & Sutcliffe in San Francisco, Los Angeles and Menlo Park are representing S.F.-based Yammer in the all-cash deal. M&A partner Richard Smith in San Francisco and corporate partner Daniel Friedland in Los Angeles led the Orrick team.

A Seattle-based Perkins Coie team is advising Microsoft on the transaction.

Co-founded in 2008 by former PayPal executive David Sacks, Yammer lets companies create private internal social networks where employees can chat online, share files or collaborate on projects. With more than 5 million users now, Yammer has raised $142 million from investors, which include Founders Fund, a venture firm led by PayPal co-founder and Facebook Inc. backer Peter Thiel, and Social+Capital Partnership, a firm partially backed by Facebook.

The acquisition will help Microsoft gain traction against competitors such as Salesforce.com, which has been adding social-related applications to its portfolio.

“When we started Yammer four years ago, we set out to do something big,” Sacks said in a statement. “We had a vision for how social networking could change the way we work. Joining Microsoft will accelerate that vision and give us access to the technologies, expertise and resources we’ll need to scale and innovate.”

Orrick’s Friedland said he’s been working for Yammer ever since 2008, when Sacks spun the company out of Geni.com, a genealogy and social networking site that he had also co-founded.

“I’m thrilled for the founder and the investors,” Friedland said. “This is really what we want to do: to work with, from beginning to end, talented founders who bring in the best investors and develop a great product.”

Other local Orrick partners on the deal include corporate partner Stephen Venuto in Menlo Park; tax partners Steven Malvey and Eric Wall in San Francisco; compensation and benefits partner Nancy Chen in Menlo Park; and IP partner Daniel Yost in Menlo Park. They were assisted in California by corporate of counsel Elizabeth Lefever in Menlo Park.

The Perkins Coie team advising Microsoft, meanwhile,includes business practice chair Stewart Landefeld, as well as technology transactions partners Richard Rohde and Kenneth Miller. Corporate partner Andrew Moore, benefits and compensation chair Kurt Linsenmayer, benefits and compensation partner Lisa McGimpsey, labor and employment partner Valerie Hughes, and tax partner Carl Crow are also advising. Brad Smith is Microsoft’s general counsel.

Perkins Coie is among a handful of firms Microsoft frequently turns to for corporate work. The firm advised on Microsoft’s $70 million purchase of online video search engine VideoSurf Inc., in November, as well as on its 2010 acquisition of Canesta Inc.

Am Law Daily staff reporter Tom Huddleston Jr. contributed.