Online gamemaker Zynga will sell its San Francisco headquarters building for around $600 million in one of the city’s biggest property sales.

Zynga agreed to sell the Showplace Square building at 650 Townsend St. to real estate investor Beacon Capital Partners. The company will remain headquartered in the building and is leasing back 185,000 square feet, or about a quarter of the 670,000-square-foot property, according to a Securities & Exchange Commission filing.

The deal values the building at nearly triple what Zynga paid — $228 million — in 2012. It is the largest single-building San Francisco deal since Salesforce’s $637 million purchase of 50 Fremont St. in 2015, according to property data firm Real Capital Analytics. The sale is expected to close before the end of July.

Zynga CEO Frank Gibeau said the sale will enable the company to benefit from a hot real estate market and reinvest money in its core business.

“We saw the opportunity to move the dollars of owning a building, and put the money into building games,” he said.

The company, which makes games such as Words With Friends and FarmVille, will sign a 12-year lease and pay around $10 million in annual rent.

“We love San Francisco. I’m born and raised here. We’re here to stay in San Francisco,” Gibeau said. “Nothing’s really changing from the employee experience.”

The building’s rising value reflects both San Francisco’s tech-fueled real estate market and the transformation of Showplace Square, also known as the Design District.

Airbnb has its headquarters nearby at 888 Brannan St. and leased 287,000 square feet in Zynga’s building in 2017. Adobe also has offices next door.

“The area is booming. There’s a lot of new restaurants going in. There’s a ton of new housing,” Gibeau said. “It’s a vibrant (area). It’s why we really want to be here in long term.”

Other advantages include proximity to Caltrain, which is about a half-mile away, and access to the Giants’ ballpark and future Warriors arena, Gibeau said.

Zynga had 1,862 full-time employees in March, with less than half in San Francisco.

Zynga was founded in 2007, moved into 650 Townsend St. in 2010 and went public a year later on the strength of FarmVille, an agriculture management game that was integrated with Facebook.

The company stumbled as FarmVille lost users. Its stock price dropped from a peak of over $14 in 2012 to below $2 in 2016. It’s since rebounded to over $6 per share this year, and 2018 revenue was $907 million, up 5% from the previous year.

Gibeau said the company is focused on mobile gaming, which accounts for 92% of its revenue. It has licensing deals for upcoming video games based on popular franchises Star Wars and Game of Thrones.

Beacon Capital Partners previously sold the Airbnb headquarters and also bought 44 Montgomery. Gibeau said Beacon was selected from a large pool of buyers after a “very rigorous process.”

Roland Li is a Chronicle staff writer. Email: roland.li@sfchronicle.com Twitter: @rolandlisf