Shares of Baidu (BIDU -0.56%) recently rallied after the Chinese tech giant posted an impressive first quarter. Its revenue rose 31% annually to 20.9 billion RMB ($3.33 billion), topping estimates by $140 million and marking the company's strongest growth since the fourth quarter of 2015.

Its non-GAAP net income surged 138% to 5.7 billion RMB ($1.7 billion), or $2.60 per share, beating expectations by $0.96. Its adjusted EBITDA climbed 69% to 6.1 billion RMB ($979 million), giving it an EBITDA margin of 29% -- compared to 21.5% in the prior-year quarter.

Baidu's mobile app.

Image source: iTunes.

Those headline numbers indicate that Baidu can still hold challengers like Tencent (TCEHY 0.10%) and Alibaba (BABA 0.28%) at bay. Let's dig deeper into Baidu's first quarter to understand why its growth is accelerating.

Rebounding demand for ads

Baidu's core online marketing business was previously hobbled by a regulatory crackdown on misleading ads in 2016, and tighter restrictions on ads before the Communist Party Congress last fall.

But with those events in the rearview mirror, Baidu's online marketing revenues grew 23% annually to 17.2 billion ($2.74 billion) during the first quarter. Its active online marketing customers rose 5% to 475,000 as its revenue per online marketing customer climbed 19% to 36,100 RMB ($5,800).

Those numbers indicate that Baidu's market-leading search engine and portals remain top priorities for advertisers, even as rivals like Tencent's WeChat gain ground.

The iQiyi spinoff

In late March, Baidu spun off its video streaming unit, iQiyi (IQ -2.62%), in an IPO that raised $2.25 billion. Baidu retained a majority stake in iQiyi, but the spin-off removed the unit's losses from its bottom line.

iQiyi's revenues rose 57% annually and accounted for 23% of Baidu's top line during the first quarter. However, Baidu's total content costs surged 59% to 4.2 billion ($669 million), mainly due to iQiyi's rising content expenses. As a result, iQiyi posted a non-GAAP operating loss of 1.02 billion RMB ($160 million), compared to an operating loss of 962 million RMB ($152 million) a year earlier.

iQiyi's mobile app.

iQiyi's mobile app. Image source: Google Play.

Therefore, the removal of iQiyi's operating expenses should significantly boost Baidu's bottom line growth starting next quarter. That's why it noted that the non-GAAP operating margin of "Baidu Core" (its core businesses excluding iQiyi) rose 12 percentage points annually to 39% during the quarter.

The divestment of its fintech unit

Baidu also plans to divest a majority stake in its financial service business, Du Xiaoman Financial, and retain 42% of the unit's outstanding shares. That move mirrors Alibaba's decision to keep Ant Financial as an affiliate, as well as JD.com's spin-off of JD Finance last year.

That move -- which is expected to close in the second quarter -- will shield Baidu's bottom line from the worrisome volatility of the fintech market, while raising cash which the company can invest in other areas of its core business.

Rising mobile revenues

The bears often argue that Baidu's relevance will fade in the age of mobile apps. Tencent, in particular, undermines Baidu by bundling various O2O (online-to-offline) services, like ride-hailing, deliveries, and mobile payments, into WeChat, the most popular mobile messaging app in China. Alibaba has also become a thorn in Baidu's side with Shenma, the second most popular mobile search engine in China.

Despite those challenges, Baidu's mobile revenues accounted for 78% of its total revenues last quarter, up from 70% in the prior-year quarter. Baidu shuttered and divested some weaker O2O units, like its food delivery unit, but it continued to expand its mobile ecosystem with DuerOS Assistant -- an Alexa-like virtual assistant which is integrated into a wide range of connected devices.

Next-gen irons in the fire

DuerOS and Apollo, Baidu's open-source platform for autonomous cars, represent the company's main plays on the growing AI market. These investments will enable Baidu to tether Internet of Things (IoT) devices and driverless vehicles to its search, mapping, and cloud services, which will widen its moat against rivals like Tencent and Alibaba.

An Apollo driverless car.

An NVIDIA-powered Apollo car. Image source: NVIDIA.

Rosy guidance and reasonable valuations

Baidu expects its second-quarter revenue to rise 26% to 33% annually, which exceeded analyst expectations. The company didn't offer any bottom-line guidance, but the spin-off of iQiyi, the divestment of its fintech unit, and ongoing job cuts (it reduced its headcount by 10% annually last quarter) should boost its earnings. Wall Street expects Baidu's earnings to rise 52% annually for the current quarter.

Baidu's stock has already rallied nearly 40% over the past 12 months, but it still trades at just 26 times forward earnings. That's a reasonable valuation for a "best in breed" Chinese tech stock that has a wide moat and plenty of irons in the fire.