When music streaming company Spotify moved to San Francisco’s Mid-Market area in 2013, its arrival was hailed by city officials as another revitalization of the troubled neighborhood.

The Swedish tech company leased three floors of office space in a 1922 building at 988 Market St. that includes the Warfield theater concert venue. It was a “perfect fit” for the music-focused company, Spotify said at the time.

But in the past month, the company moved out before its lease ended — and will no longer be eligible for the controversial Mid-Market payroll tax break. The 2011 program gave nine companies — including Spotify, Twitter and Zendesk — a tax break in exchange for opening offices in the neighborhood and providing community benefits like donations to nonprofits.

Spotify’s departure underscores continued challenges in the Mid-Market area, where tech investment has brought thousands of high-paying jobs but hasn’t changed a challenging street milieu of poverty, homelessness and drug dealing.

Spotify’s new office is the Merchants Exchange Building in the north Financial District, which includes the swanky Julia Morgan Ballroom. The company moved in about a month ago, said a Spotify security guard who gave his first name as Charles.

The change was motivated in part because some Spotify workers felt unsafe, said two former Spotify workers, who requested anonymity to avoid repercussions from former or current employers. The Mid-Market and Tenderloin neighborhoods have some of the highest violent crime and poverty rates in the city, according to government data.

Last year, a female Spotify employee was slapped in the face by a homeless woman near the office, the former employees said. A person in the real estate industry familiar with the building who was not authorized to speak publicly about the episode also confirmed that the incident happened.

“There were safety concerns,” one of the former employees said, including drug dealing on the corner. “I think it really alarmed people.”

Employees who had moved from Sweden were unaccustomed to San Francisco’s homelessness crisis, the person added.

Spotify’s new Financial District office is the center of old money, across from Wells Fargo headquarters and a block from the onetime headquarters of Bank of America.

Spotify’s former Mid-Market neighbor was the Crazy Horse, a strip club, and across the street is the empty 6x6 shopping mall, which has struggled to find retail tenants.

Spotify didn’t respond to requests for comment.

Its San Francisco workforce has fluctuated since it went public in April. There were 30 to 50 employees in San Francisco this year as the company sought to cut costs, said one of the former employees.

The company is now hiring mostly in Stockholm and New York. The website lists 72 job openings at its Stockholm headquarters, 109 in New York, 28 in London, four in Los Angeles and two in San Francisco.

Spotify leased 13,500 square feet in 2013, enough space for about 80 employees. At its new Financial District office, it is subleasing 15,650 square feet from tech company Discovia, with the deal expiring next October, according to brokerage data.

As part of its tax break, Spotify agreed to volunteer and provide meals at nonprofits including the Cutting Ball Theater, and to subsidize art and music tickets in the Tenderloin, according to a community benefit pact it signed this year.

Spotify has donated more than $3,000, purchased more than $182,282 in food services, held five events and completed 12½ volunteer hours from January through November, according to city filings.

“The community benefit agreements have resulted in meaningful engagement between the companies and the community. We’ve seen the companies stay and grow,” said Bill Barnes, a spokesman for the city administrator.

Del Seymour, founder of nonprofit job training program Code Tenderloin and a neighborhood tour guide, said Spotify has been a “steady partner.”

“Spotify has sponsored events, attended graduations and donated equipment,” he said. “We have not done any recent company tours, although we have Spotify individuals from time to time.”

But Don Falk, executive director of the Tenderloin Neighborhood Development Corp., a nonprofit affordable housing operator, said that Spotify’s community benefit agreement was “relatively weak,” in part because of the soft economy at the time it was signed.

Spotify hasn’t applied for a tax exclusion for the current year. It would be ineligible for the time period after it moved since its office is no longer in the area, according to the city administrator’s office. The deadline to apply is the end of December.

Tenderloin activists acknowledged a safety problem.

“Are things better than a month ago? Yes. But it’s not acceptable,” said Randy Shaw, executive director of Tenderloin Housing Clinic, which works with low-income tenants.

Shaw said the Warfield building’s block is relatively safe, but the next block west has crime problems. “I don’t see any problems there. That block to me seems very good to me,” he said.

Other tech companies in the building include Zendesk, Match Group and Benchmark, a venture capital firm known for its investment in Uber.

Zendesk leased space in 988 Market as part of a recent expansion of its Mid-Market headquarters, which is spread across several buildings.

“There is enormous need every day on the streets, but there’s also enormous potential,” Tiffany Apczynski, Zendesk vice president of public policy and social impact, said in a statement. “We are committed to cultivating what makes this neighborhood special, now and in the future.”

Spotify hasn’t entirely left the area. On Friday, the Powell Street BART Station was filled with colorful Spotify ads, highlighting the company’s most popular songs and playlists of 2018.

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