Shares of Alphabet dipped more than 5 percent after-hours, before steadying with a 2.7 percent loss at $1,149.93.

Though growing demand for pricey ads on mobile apps has kept Google's core ad business surging, the company has moved aggressively to maintain dominance and diversify sales. Expenses jumped 27 percent to $24.7 billion in the fourth quarter from the year-earlier period.

Google bought ads during major sports events to market its new Pixel 2 smartphone and YouTube television service. It slashed prices on other hardware in the race to get online search and media streaming devices into people's homes. Google continued to quickly add staff to its enterprise sales unit.

A growing portion of revenue has been spent on having the Google search engine set as the default option on products and services such as Apple Inc's iPhone and Mozilla's Firefox browser.

Alphabet Chief Financial Officer Ruth Porat told analysts in a post-earnings conference call that higher marketing costs coincided with holidays and that payments to partners such as Apple and Mozilla would steady in coming quarters.

Investments are paying off, Google Chief Executive Sundar Pichai said, noting that cloud computing is generating $1 billion in quarterly sales. He said Google's G Suite workplace software package had doubled its customers to 4 million in two years, as Reuters first reported earlier on Thursday.

Financial analysts looked past the spending.

"Overall, it was a good quarter. Advertising revenue is still up significantly," Ivan Feinseth of Tigress Financial Partners said in an email.

Fourth-quarter sales increased 24 percent to $32.3 billion, above the average analysts' estimate of $31.9 billion, according to Thomson Reuters I/B/E/S. Adjusted quarterly profit of $6.8 billion, or $9.70 per share, missed estimates of $7 billion, or $10 per share.

The profit figure excludes a $9.9 billion tax charge as Alphabet joined much of corporate America in reporting large one-time expenses in the fourth quarter due to U.S. legislation enacted in December that lowers corporate rates.

The tax law has given companies more affordable access to overseas profits, and Porat said Alphabet would make a "modest increase" in share buybacks with an additional allocation of $8.6 billion.

The growing use of smartphones worldwide has been a bonanza for social media company Facebook Inc and Google, which research firm EMarketer estimates together account for nearly 60 percent of mobile ad sales.

Google sells ad space on its search engine, its fast-growing YouTube video streaming service and a network of third-party websites and apps.

The company's computer algorithms have become more effective at delivering mobile ads likely to make customers sit through commercials, install an app or visit a website.

Led by such ads, Alphabet generated $110.9 billion in full-year revenue, up 23 percent from 2016 and topping $100 billion for the first time. Profit fell 35 percent to $12.6 billion because of the tax bill and a separate charge last summer for a $2.7 billion European Union antitrust fine, which is under appeal.

"The company's continued strong top-line growth and myriad new opportunities to drive future growth remain the keys to the stock," MoffettNathanson analyst Michael Nathanson said in an email.

Alphabet is attempting to maintain sales growth through new businesses, experimenting with operating a fleet of self-driving taxis through Waymo and licensing medical technology at Verily.

Non-advertising revenue from Google combined with revenue from Verily and the other Alphabet companies was $15.5 billion in 2017, accounting for about 14 percent of total revenue, compared to $10.9 billion, or 12 percent, in 2016.

Alphabet also said on Thursday that veteran board member John Hennessy took over as chairman the day before from Eric Schmidt, a long-time Google executive who will remain a board member and technical adviser.

The potential for further regulation on privacy, monopolistic business practices or content vetting is among investors' top concerns about tech companies such as Alphabet and Amazon.com Inc that are tapping their unrivaled consumer behavior data to branch beyond their core businesses.

MKM Partners analyst Rob Sanderson said in a note to clients last month that Google had "the most unrecognized value" of big publicly traded tech companies despite some concerns about regulatory issues.