SAN FRANCISCO — Zynga is putting all its chips on a game called survival.

The company, which practically invented the notion of using Facebook as a games platform, is firing employees, shutting games and losing players. It warned that its third-quarter numbers would be a pre-Halloween horror, and so investors naturally started thinking about the apocalypse.

The results, released after the market closed Wednesday, were not quite as bad as that. In addition, the company announced a partnership to offer online casino games in Britain where gamblers can wager real money. Such games, which have been banned in the United States, are promoted as highly profitable.

Third-quarter revenue was $317 million, an improvement over the $300 million to $305 million the company forecast in early October when it warned that tough times were ahead. The number was also significantly higher than the $256 million that downbeat analysts had expected. But revenue was only 3 percent better than 2011.

Still, the stock immediately spiked, rising as much as 30 cents in after-hours trading to $2.42. Zynga shares are down 75 percent from their public offering price last December, and have dropped even more from the level at which executives and early investors cashed out last spring in an unusual $500 million secondary offering.