Alibaba Group (BABA) may still be the leading e-commerce company in China, but JD.com Inc. (JD), long a second-place player, is closing in.

Citing data from Analysys International Enfodesk, eMarketer, the market research firm, said Alibaba’s Tmall consumer online shopping platform had 51.3% market share at the end of the second quarter compared to 32.9% for JD.com. Rewind to 2015 and JD.com controlled just 17.7% of the online commerce market while Tmall was at 54.6%. (See also: Why Amazon Is Losing to JD.com and Wal-Mart.)

Room for Two?

According to eMarketer, JD.com is stealing share from smaller online retailers, which is closing the gap with Tmall. A movement among consumers to purchase direct rather than via third parties is also helping it grab more customers. It’s also making a push into Southeast Asia to keep up with Alibaba, investing in ride hailing company Go-Jek in Indonesia and reportedly in talks with Central Group, the Thai retailer to open a joint e-commerce venture in Thailand, reported eMarketer. Still, the company is struggling with losses, which was the case when it reported second-quarter results. For the three months ended in June, JD.com weighed in with a loss of 496.4 million yuan ($74.43 million), up from 252.3 million yuan in the same period a year earlier. Marketing expenses rose 63% to 4.1 billion yuan, largely because of a promotional events in June. (See also: JD.com to Battle Alibaba for China's Luxury Buys.)

Although Alibaba is still the undisputed leader in Chinese e-commerce, MKM Partners thinks there is room for both of them. Last month, analyst Rob Sanderson upgraded JD.com to buy from neutral and raised his price target to $51 from $33. "The stock has pulled back sharply on margin/competition concern. While our conviction in Alibaba remains unchanged, we think the China retail opportunity is sufficiently large to support a strong number two, that JD has a sustainably differentiated position and we remain encouraged by robust consumption trends and rapid shift to e-commerce in the region," the analyst wrote in a note to clients at the time. The Wall Street watcher said a survey of consumers in China showed there is a large and consistent group of consumers—20% of those polled—that prefer JD.com’s direct sales platform to Alibaba’s marketplace, in which third parties hawk their goods.