Google parent Alphabet
Shares jumped more than five percent after hours.
Growth in the company's traffic acquisition costs, a key expense, decreased for the first time in three years compared with the year-ago period. Operating margin rose to 24 percent excluding a US$5 billion antitrust fine, up from 22.5 percent last quarter.
Adjusted earnings per share were US$10.58, which beat the US$9.52 average estimate in research aggregated by Thomson Reuters. Some analysts excluded other items as well, and Alphabet also beat that consensus of US$9.59.
Alphabet said earnings per share were US$11.75 before adjustments, which removes US$1.1 billion in investment income from a new accounting standard for unrealized gains as well as the fine issued last week by the European Commission. Google is appealing the ruling, which found it abused its dominance in mobile software.
Alphabet's US$32.66 billion in second-quarter revenue, 86 percent of which came from Google's advertising business, beat an average estimate of US$32.17 billion.
Google's dominance in online advertising has been challenged this year by the antitrust battle over its Android mobile software and other regulatory actions.
But the issues have yet to halt Google, which has grown quarterly revenue at least 20 percent year-over-year for two straight years.
A new privacy law enacted by the EU in May led the company to revise user privacy disclosures and clamp down on how it shares data with advertising customers. Google also has tweaked its comparison shopping service as it strives to comply with an EU ruling from last year, and it plans to soon release changes to how it handles political ads.
Alphabet shares also have been lifted, according to analysts, by a forecast that expense growth would level off in the second quarter because the company entered the second year of a costly deal to make Google the default search provider on iPhones.
Still, Alphabet's outlook remains tempered by cost concerns, Canaccord Genuity analyst Michael Graham said in a report this month.
Alphabet trails Facebook, Amazon
Cost increases have come across the enterprise. Government pressure to improve moderation of user-created content has forced Google to hire more analysts. YouTube, a Google-owned streaming service, has increased spending on video content to keep consumers from shifting to offerings from Netflix Inc
Amazon's encroachment into advertising has threatened Google's lucrative deals with media companies and advertisers.
At least three financial analysts who follow Google have said this year that separating its various advertising businesses in financial results would help investors understand how the competition is affecting the company.
Google, though, has increasingly linked together its services technologically through automated ad-buying tools that empower algorithms rather than humans to pick where ads are placed.
Macquarie Group senior analyst Benjamin Schachter wrote in a report this month that "we are approaching a point where we (and we believe The Street collectively) are not understanding the size of search vs YouTube vs programmatic, which may lead to increasing volatility" in share price.
Shares of Alphabet have gained 13 percent this year, compared with 16 percent for Facebook, 51 percent for Amazon and 76 percent for Twitter.
(Reporting by Arjun Panchadar in Bengaluru and Paresh Dave in San Francisco; editing by Patrick Graham and Lisa Shumaker)