Uber's decision to abandon its efforts in China will free up capital for other priorities, including its aggressive push to develop its own self-driving technology. Image source: Uber Technologies.

After spending at least $2 billion trying to build a significant presence in China, ride-hailing giant Uber Technologies has given up, cutting a deal with its largest rival.

Uber will swap its China operation for a minority stake in Didi Chuxing Technology, the dominant player in China's booming ride-hailing market, the companies announced on Monday.

The agreement marks the end of an immensely expensive war for market share that had led to huge losses at both Didi and Uber's China subsidiary. It might also be the beginning of Uber's march toward its long-awaited initial public offering. 

The deal's structure turns rivals into partners

The deal's structure seems intended to let investors in both companies know that Didi and Uber have buried the proverbial hatchet.

Under the deal, UberChina, a subsidiary in which Uber owned an 87.5% stake, will merge with Didi. In exchange, Uber and the investors in its UberChina unit will get a roughly 20% stake in post-merger Didi. Didi will also make a $1 billion equity investment in Uber, making the two arch-rivals into business partners. 

Didi was valued at about $28 billion in its most recent fundraising round. This deal values post-merger Didi at about $35 billion, meaning Uber's stake in Didi will be worth roughly $7 billion. 

What Uber gets out of the deal

First and foremost, Uber gets a graceful exit from a situation that was increasingly untenable -- and that might have become a roadblock to an eventual IPO. 

Both Uber and Didi were spending millions to try to lure drivers and build out their networks -- but Didi, whose investors include big Chinese tech companies Alibaba (BABA 0.28%) and Tencent Holdings (TCEHY 0.10%) as well as China's politically powerful sovereign-wealth fund, always seemed to have the upper hand in the battle for the Chinese market. 

Uber's investors were growing uneasy about the huge spending. Bloomberg reported last month that some of Uber's institutional investors had been pushing the Silicon Valley company's management to bring the fight to an end by cutting a deal with Didi. Now, instead of owning a huge cash drain, Uber owns a fifth of Didi's near-monopoly presence in China.

Not incidentally, Uber's exit from the money-torching China business will improve its near-term financial outlook considerably, which, in turn, should help its valuation once the company begins ramping up toward its long-awaited IPO.

It also allows Uber to spend money and management time on other priorities. The company is fighting regulators in Europe and some U.S. states, investing heavily in an effort to develop self-driving technology, including its own mapping system, and may be gearing up for an expansion in India. Indian automaker Tata Motors (TTM) invested about $100 million in Uber last year. 

The upshot: A good exit from a tough situation 

Under pressure from investors, Uber CEO Travis Kalanick made the best deal he could, and it looks like a good one. 

Yes, Uber had to retreat from China. But it got a good price for its China business and a meaningful stake in the company that dominates China's market, and it made peace with a powerful player that has been backing Uber's rivals in other markets around the world -- all in one deal. 

Not bad at all. So, when's the IPO?