(Reuters) - After a bruising two-year battle, ride-hailing firm Uber is selling its China operations to bigger local rival Didi Chuxing in a deal that will give Uber a one-fifth stake in Didi.

The merged entity is worth around $35 billion - combining Didi’s most recent $28 billion valuation and Uber China’s $7 billion worth - said a source familiar with the matter who did not want to be named before the deal was made public.

Didi confirmed the agreement on its official microblog, but gave no valuation. In a posting on Uber’s website, CEO Travis Kalanick said San Francisco-based Uber Technologies would have a one-fifth stake in Didi, making it the Chinese firm’s biggest shareholder. Kalanick will join Didi’s board, with Didi Chuxing chief Cheng Wei joining the Uber board.

Uber will continue to operate independently, the Didi posting said. “Cooperating with Uber will give the entire mobile travel industry a healthier order and a period of a higher level of development,” it said.

China has been a challenging market for Uber, which has spent billions of dollars in a price war with Didi.

Both firms spent heavily to attract riders with discounts and both also raised billions in recent fundraisings. Uber is profitable in the United States, Canada and about 100 other cities.

In an internal message to staff viewed by Reuters, Kalanick wrote: “Sustainably serving China’s cities, and the riders and drivers who live in them, is only possible with profitability. This merger paves the way for our team and Didi’s to partner on an enormous mission, and it frees up substantial resources for bold initiatives focused on the future of cities - from self-driving technology to the future of food and logistics.”

He said Uber was operating in more than 60 cities in China and “doing more than 150 million trips a month.” Didi, however, claims 87 percent of the Chinese market for private vehicle ride-hailing.

Richard Ji, Hong Kong-based co-founder of All-Stars Investment Ltd, which manages about $900 million and owns Didi stock, said the deal makes “huge sense”.

“Uber faces an uphill task in China especially since Didi is multiple times larger by transaction value and city coverage,” he said.

“This will lead to favorable outcomes for both companies. The biggest benefit is cost savings, they no longer have to give out subsidies to drivers and passengers. It will give pricing power as the new entity will become the dominant player. That means profitability will come sooner than later.”

Under the deal, Didi will also invest $1 billion in Uber, which operates globally outside China, the source said, adding to a series of deals and joint ventures Didi has struck in recent years.

Slideshow ( 6 images )

INTERNATIONAL AMBITION

Analysts said Didi’s acquisition signals its readiness to step beyond its home market.

“This clearly shows Didi’s global ambitions and its desire to work together with Uber to tap Chinese travelers, who are going out in big numbers. There’s a possibility the two could work together in other markets,” All-Stars Investment’s Ji said.

Didi said in its posting it will look to expand its international business and enter markets like Hong Kong, Taiwan, Macau, Japan, South Korea, Europe and Russia.

Slideshow ( 6 images )

Didi - itself created last year from a merger of two firms backed respectively by e-commerce giant Alibaba Group BABA.N and social network firm Tencent 0700.HK - has invested $100 million in Lyft, Uber's main rival in the United States.

It has also formed an alliance with Lyft, India’s ride service Ola and Southeast Asia’s ride-hailing startup Grab in an effort to compete with Uber’s global dominance.

The Didi deal is the latest sign that global Internet and technology companies are struggling to break into China’s cut-throat market, where local entrepreneurs have built formidable businesses, partly helped by a supportive government.

All of China's technology heavyweights will be stakeholders in Didi, as Uber shareholder Baidu BIDU.O will gain a stake. Apple Inc AAPL.O recently made a rare $1 billion investment in Didi.

China last week issued guidelines that establish a long-awaited framework for the booming ride-hailing industry and remove uncertainty for firms such as Didi and Uber.

It was unclear whether the deal would need to be cleared by China’s Ministry of Commerce (MOFCOM), the anti-trust regulator.

“Given Didi’s reported high market share, any increment would attract MOFCOM’s attention. But for the parties to seek pre-closing approval, each has to meet the minimum sales threshold. That’s where it’s unclear whether an anti-trust filing would be required,” said Marc Waha, partner at Norton Rose Fulbright.