Baidu (NASDAQ:BIDU) and Yandex (NASDAQ:YNDX) own the largest internet search engines in China and Russia, respectively. Both stocks performed well this year, with Baidu jumping nearly 65% and Yandex advancing almost 60%.

But after those big rallies, is either stock still worth buying? Let's take a closer look at their business models, growth trajectories, and valuations to find out.

A businesswoman touches a search bar.

Image source: Getty Images.

What Baidu and Yandex do

Baidu controls about 80% of China's internet search market. It soundly conquered the market after Alphabet's (NASDAQ:GOOG) (NASDAQ:GOOGL) Google left the country in 2010. Like Google, Baidu expanded its ecosystem to include news sites, mapping services, streaming video, an artificial intelligence-powered virtual assistant, and even autonomous cars. It's also expanding its online-to-offline (O2O) ecosystem, which allows users to hail rides, order goods, make mobile payments, and access other services without leaving its mobile app.

Yandex still competes against Google in Russia, but its 49% market share remains slightly higher than Google's 47%. Yandex notably handles "CrazyFont" -- Russian written in English without using Cyrillic letters (popular among Russians who don't have Cyrillic keyboards) -- better than Google. Yandex's expanding ecosystem includes portal sites, e-commerce marketplaces, ride-hailing services, and online classifieds.

How fast Baidu and Yandex are growing

Baidu's revenue rose 35% in 2015 but just 6% in 2016, due to two one-time events -- a government crackdown on misleading ads (mostly for healthcare products) and a swap of its stake in online travel agency Qunar for one in Ctrip. With these issues now in the rearview mirror, analysts expect Baidu's revenue to rise 22% this year. Most of Baidu's revenue still comes from its advertising business, which accounted for 86% of its top line last quarter.

Baidu's current game plan is to divest or spin off weaker businesses (like its food delivery subsidiary) and increase its investments in the mobile and AI markets. Those moves could widen its moat against rivals like WeChat maker Tencent (OTC:TCEHY) and e-commerce titan Alibaba (NYSE:BABA) -- which have both been aggressively expanding their ecosystems.

Yandex's revenue rose 18% in 2015, and accelerated to 27% growth in 2016. Analysts expect 23% growth this year. Advertising revenue accounted for 96% of its sales last quarter.

Yandex is investing heavily in improving its core search technology, expanding its language capabilities, and refining its targeted ads. It recently launched Yandex.Radar, a search traffic and browser user analytics tool, an open-source machine learning library called CatBoost, and Alice, the first AI-powered virtual assistant designed for the Russian market. It also merged its Yandex.Taxi service with Uber's operations in Russia and five neighboring countries. These moves could all widen its moat against Google and future-proof its core business.

How profitable Baidu and Yandex are

Expanding a search-based ecosystem is expensive, and those costs caused Baidu's and Yandex's operating margins to fall over the past five years.

BIDU Operating Margin (TTM) Chart

Data source: YCharts.

However, those margin declines seem to be bottoming out. Baidu's net income rose 155% in 2015, but dropped 53% last year on the aforementioned headwinds. Analysts expect its earnings to rebound 24% this year. Yandex's net income fell 11% in 2015 but climbed 16% last year. Wall Street expects 5% growth this year.

Neither stock looks cheap relative to their earnings growth. Baidu trades at 50 times trailing earnings and 35 times forward earnings. Yandex has a trailing P/E of 75, but its forward P/E of 29 looks more reasonable.

However, we should remember that China and Russia have internet penetration rates of just 71% and 52%, respectively, compared to an 89% penetration rate in the U.S. Those lower percentages give Baidu and Yandex more room to grow than search engine providers in more mature markets -- so they might deserve their premium valuations.

The winner: Baidu

Baidu needs to fend off ecosystem challengers like Tencent and Alibaba, but it doesn't need to counter Google. Yandex is holding Google at bay in Russia, but it might lose its lead if Google invests more heavily in Russia before the ruble strengthens again.

China's economy is also growing at a much faster rate than Russia's, which gives Baidu a healthier core market than Yandex. Lastly, Baidu's aggressive investments in AI and autonomous cars, which has already attracted a long list of U.S. tech giants, put it in a better position to become a global tech powerhouse than Yandex, which generally partners with smaller companies.

I personally own shares of Baidu, and I think they have more room to run. But I'm a bit wary of Yandex, which faces much tougher competition over the long term.

This article represents the opinion of the writer, who may disagree with the “official” recommendation position of a Motley Fool premium advisory service. We’re motley! Questioning an investing thesis -- even one of our own -- helps us all think critically about investing and make decisions that help us become smarter, happier, and richer.