Yahoo, with CEO Marissa Mayer at the helm, has turned a profit in the second-quarter earnings, despite low expectations, the company said Tuesday.

Yahoo reported quarterly sales that fell slightly short of both Wall Street's expectations and lower than what it reported a year ago. However, excluding revenue shared with advertising partners, Yahoo's sales were just under $1.1 billion for the quarter ended June 30, down about 1 percent from last year.

Yahoo's core profit for the quarter, excluding stock-based compensation and some one-time expenses, increased to  $331 million, up 46% compared to last year. Excluding some expenses, Yahoo earned 35 cents per share, beating the 30 cents per share consensus forecast of analysts polled by Thomson Reuters.

"I'm encouraged by Yahoo's performance," Yahoo CEO Marissa Mayer said in a written statement. "Our business saw continued stability, and we launched more products than ever before, introducing a significant new product almost every week."

Ever since ex-Google executive Marissa Mayer took over as the struggling company's CEO in July 2012,  Mayer has coordinated 17 acquisitions, including a $1.1 billion purchase of Internet blogging service Tumblr, Yahoo's biggest in a decade. The company's home page, email and Flickr photo service have all been redesigned, and a few mobile applications have been upgraded, helping to increase use of the company's Internet services.

As a result, the company's revenue is increasing, if ever so slightly, after three straight years of decline. However, Mayer can't take much credit for Yahoo's resurgent stock. Most of the 75 percent increase in the shares has been driven by the rising value of the company's stake in Alibaba Group, which owns a network of bustling e-commerce and digital payment services in China.

While Alibaba has boosted Yahoo's stock in the short term, Mayer is trying to set the stage for a comeback in the long term.

"As I've said before, companies with the best talent win, and it's clear we're now back in the game," Mayer declared during Yahoo's most recent earnings conference call in April.