(Reuters) - Alphabet Inc on Monday reported that expenses from its Google search business grew more slowly in the second quarter while revenue rose more steeply than analysts had anticipated, boosting profit above Wall Street targets and pushing shares up 3.6 percent after hours.

Google’s dominance in online advertising has been challenged this year by the antitrust battle over its Android mobile software, which led to a $5 billion fine for the quarter, and other regulatory actions, including new European privacy rules.

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 and expanding media conglomerates such as AT&T Inc.

But those issues have yet to halt Alphabet, which has grown quarterly revenue at least 20 percent year-over-year for two straight years.

“There was never a question about Google’s dominance of a buoyant digital ads market,” said analyst Richard Kramer of Arete Research.

The quarterly growth rate of what the company pays ad partners, called traffic acquisition costs, fell for the first time in three years, which Atlantic Equities analyst James Cordwell described as the “most impressive” piece of the results.

Google Chief Executive Sundar Pichai told analysts that investments in artificial intelligence software meant to better predict where to place ads are making its services more attractive to advertisers. The company is selling more ads as its YouTube video service and Google search grow globally, he said.

Profit margins have dipped as more ads get shown on mobile devices, where Apple Inc and other firms charge fees to distribute Google search on their devices and apps.

But Google in the second quarter entered the second year of its latest multi-year deal with Apple, which analysts said helped even out costs.

A logo is pictured at Google's European Engineering Center in Zurich, Switzerland July 19, 2018. REUTERS/Arnd Wiegmann

Operating margin rose to 24 percent from 22 percent last quarter, excluding the $5 billion antitrust fine issued last week by the European Commission over Google’s anticompetitive licensing of Android software. The margin was down from 26 percent a year ago.

Net profit dropped to $3.2 billion from $3.5 billion, due to the fine, but analysts focused on operating results.

Adjusted earnings per share were $10.58, excluding the fine and the effects of other investments. Analysts estimated $9.52 per share, according to research aggregated by Thomson Reuters. Some analysts excluded other items as well, and Alphabet also beat that consensus of $9.59.

Alphabet’s $32.66 billion in second-quarter revenue, 86 percent of which came from Google’s advertising business, beat an average estimate of $32.17 billion.

The rest of the revenue came from Google’s non-advertising businesses, which include selling apps, gadgets and cloud computing services, and ventures such as offering internet service.

The newer businesses are sucking up investments as Google adds data centers and employees to support them. But Alphabet Chief Financial Officer Ruth Porat told analysts on Monday that the advertising unit is also getting new capital.

Alphabet, Facebook Inc and other leading application makers have become big forces in advertising as consumers globally, and in turn, advertisers devote increasing attention to smartphone and TV apps instead of newspapers and traditional TV broadcasts.

Pichai said the company had opportunity to show ads on Google Home smart speakers and Google Maps and was slowly determining the best way to do so.

Company shares have benefited from easing regulatory concerns. A new privacy law enacted by the EU in May has had a minimal effect on Google’s advertising business, and smartphone industry executives have described the EU antitrust case over Android as too late to matter. The company has cautioned that it is too early to measure the impact on both fronts.

But Alphabet’s outlook is tempered by cost concerns, and Amazon.com Inc’s encroachment into advertising has threatened Google’s lucrative deals with media companies and advertisers.

Alphabet trails Facebook, Amazon and Twitter Inc in valuation as measured by the ratio of enterprise value to expected earnings. Its enterprise value, or market capitalization and debt minus cash, trades at 13 times expected earnings for the next 12 months, compared with about 14 times for Facebook, 24 times for Twitter and 26 times for Amazon, according to TR data.