Taxi-booking app Uber has agreed to sell its business in China to rival Didi Chuxing.
The two firms have been fierce competitors, but Didi Chuxing dominates the Chinese market with an 87% share.
Uber China launched in 2014 but has failed to make any profit so far.
Cheng Wei, founder and chief executive of Didi Chuxing, said the two companies had "learned a great deal from each other over the past two years in China's burgeoning new economy".
He added that the deal would "set the mobile transportation industry on a healthier, more sustainable path of growth at a higher level".
As part of the deal, Mr Cheng will join the board of Uber, while Uber chief executive Travis Kalanick will join Didi's board.
Uber's China business will retain its separate branding while US-based Uber Technologies will hold a stake of about 17.5% in the combined company.
Didi Chuxing is backed by Chinese internet giants Tencent and Alibaba, and has also invested in Uber's rival US taxi-booking service Lyft.
Uber has been struggling to break into the Chinese market despite having Chinese search engine Baidu as an investor.
In February, the company admitted it was losing more than $1bn a year in China, spending huge sums to subsidise discounted fares.
"Funding their China dreams was becoming too expensive for Uber," Duncan Clark, chairman of Beijing-based consultancy BDA, told the BBC.
"Many saw it as an obstacle to their own IPO (Initial Public Offering)."
Uber chief Travis Kalanick said that "as an entrepreneur, I've learned that being successful is about listening to your head as well as following your heart".
"Getting to profitability is the only way to build a sustainable business that can best serve Chinese riders, drivers and cities over the long term."
The fierce rivalry had led both companies to heavily subsidise their journeys. The merger is likely to see fewer such subsidies.
"One thing to watch carefully is how quickly consumers feel the impact as subsidies are withdrawn," Mr Clark added.
Analysis: Karishma Vaswani, Asia business correspondent
If you can't beat them, join them - that may be what Uber's ultra ambitious Travis Kalanick was thinking. This deal may be Uber's best available option on the table.
Uber put up a good fight, there's no doubt about it. And it may not all be bad news.
If the departure from the Chinese market means a sizeable stake in the biggest ride-sharing player in the world's second largest economy, which currently has a potential customer base of some 750 million people, and that's only going to grow - then that's not too shabby.
Recognising this was one fight he wasn't going to win, may well turn out to be a sign of Mr Kalanick's maturity and business acumen in the future.
Didi Chuxing in brief:
- China's number one taxi-booking app.
- Claims to have an almost 90% market share and some 14 million journeys every day.
- The company is the product of a merger: In February 2015, Didi Dache and Kuaidi Dache merged to form Didi Kuaidi, later renamed Didi Chuxing.
- It is the driving force behind an alliance with India's Ola, South East Asia's Grab and US firm Lyft, allowing users to use their apps to hail from the partner services when abroad.
The deal with Didi Chuxing comes just days after China agreed to provide a legal framework for taxi-ordering apps.
Both Uber and Didi have welcomed the decision, having previously operated in a legal grey area in the country.
While the apps are widely popular, they have undermined business for normal taxis and have been met with protests by cab drivers.
The new rules will take effect on 1 November and will, among other things, forbid such platforms to operate below cost.