Didi Chuxing, the leading ride-hailing service in China, has reached a deal to acquire Uber’s China operations in a merger that could be worth up to $35 billion USD.

Didi will take over Uber’s China business, while the U.S. company will become Didi’s largest shareholder. The news comes days after Chinese regulators announced the upcoming legalization of ride-hailing services in the country.

According to sources who spoke to Bloomberg, investors in Uber China, which includes search giant Baidu, will take a 20 percent stake in the newly merged entity, and Didi will make a $1 billion USD investment in Uber Global at a $68 billion USD  valuation to kick off the partnership. Uber will maintain management of their app in China for the time being.

[Update: Didi confirmed the acquisition in a statement, noting that Uber Global will take a 5.89 percent stake in the newly merged entity with a preferred equity interest worth 17.7 percent economic interest in Didi. Chinese shareholders, including Baidu, will receive a 2.3 percent stake in Didi.

Uber founder Travis Kalanick will join the board of Didi while Didi founder Cheng Wei will join the board of Uber.]

The deal marks the end of a grueling rivalry between the two services, which saw both companies shell out billions in marketing and subsidies. Uber also set a new benchmark for U.S. tech companies with their China entry, opening an entity financially distinct from their parent company, Uber Global.

The landmark consolidation brings together a host of the country’s top investors, with Baidu now joining Alibaba and Tencent, who oversaw investments in Kuaidi Dache and Didi Dache respectively before the two ride services merged in early 2015.

State-backed Chinese insurance giant China Life had already invested in both companies, investing $200 million in Uber in 2015 before injecting $600 million in Didi last month, raising suspicion that the ride sharing companies were in merger discussions.

According to an internal blog post by Uber CEO Travis Kalanick on the subject of the deal, “Uber and Didi Chuxing are investing billions of dollars in China and both companies have yet to turn a profit there. Getting to profitability is the only way to build a sustainable business.”