Facebook topped analysts estimates with its third-quarter earnings release, thanks to stronger than expected mobile advertising revenue.

The Menlo Park, Calif.-based company, which has struggled since its initial public offering in May, reported third-quarter earnings of $311 million, or 12 cents a share, on revenue of $1.26 billion, up from net income of $227 million a year ago. Those numbers beat analyst expectations. Wall Street had estimated the company would earn $285.12 million, or 11 cents a share, on revenue of $1.23 billion.

The company said 14% of its revenue came from mobile advertising. Three months ago, when Facebook announced lackluster second-quarter results, the company had no measurable revenue from mobile advertising.

Update: “I want to dispel this myth Facebook can’t make money on mobile,” founder and CEO Mark Zuckerberg said in a conference call with analysts Tuesday afternoon. “That may have seemed true earlier this year because we hadn’t started trying yet.”

Zuckerberg said that on a given day, there is a 40% chance a desktop user will visit Facebook. That number, he said, jumps to 70% for mobile users. He also repeated a previous argument that in coming years smartphones will far outnumber desktop computers worldwide.

“Our mobile user base is huge, growing and even more engaged than our desktop user base,” Chief Operating Officer Sheryl Sandberg added. “Our results to date suggest we’re on the right track….we have become one of the largest mobile advertising platforms in less than eight months.”

On a year-over-year basis, Facebook served 27% more ads in the third quarter. Chief Financial Officer David Ebersman said the increase could primarily be attributed to the increase in its user base, which topped one billion in the quarter. A 7% increase in the ad rate Facebook charged, however, was due to increase ad placement in newsfeed on the desktop site, Ebersman said,

Investors shrugged off a decline in desktop advertising revenue and instead responded to the renewed focus on its mobile business, pushing Facebook shares up as much as 1% in afterhours trading. Executives were expected to speak with analysts in a conference call at 5pm ET Tuesday afternoon.

“We opened up a lot of inventory in mobile this quarter and we had a lot of advertisers shift from desktop to mobile,” Ebersman said.

On the same day that Zynga said it would layoff 100 employees in Austin and close its Boston office, Facebook said it continued to depend less and less on Zynga. Revenue from Zynga games accounted for 7% of Facebook’s total revenue in the three months ended Sept. 30, down from 12% a year ago and 10% a year ago.

“Gaming on Facebook is not doing as well as I’d like,” Zuckerberg said. But while Zynga revenue declined, “revenue from the rest of our gaming partners is up.”