SAN FRANCISCO — The only thing changing faster than who is winning the race in the cutthroat world of ride hailing are the shifting behind-the-scenes allegiances between those companies and investors.

At the moment, Uber, the ride-hailing behemoth, is nearing a deal to receive billions of dollars in funding from SoftBank, the Japanese conglomerate, according to three people with knowledge of the matter, who asked not to be identified because the talks are confidential.

SoftBank is one of the largest investors in Didi Chuxing, one of Uber’s largest former foes. Didi also happens to be a major investor in Lyft, Uber’s biggest American rival. And, according to three people familiar with the discussions, Lyft has held recent talks to raise funding from Alphabet, whose venture capital arm also happens to be a major shareholder in Uber.

The tangled state of affairs has made for strange bedfellows, and has helped to forge occasional alliances between companies. But it has also put companies in difficult positions when they have to decide which investors to accept money from — and what strings may be attached.

“If you believe the ride-share industry is big enough, you believe that even if you have a losing investment in one of the two competitors, the winner will be big enough to justify the loss,” said Quin Garcia, managing director of Autotech Ventures, a firm that invests in ground transportation start-ups and has invested in Lyft.

Uber’s position is perhaps the most precarious. As the San Francisco-based company has spent the past nine months grappling with scandal after scandal over its culture and business practices, competitors like Lyft and Ola have gained traction in key markets. Last month, Uber appointed a new chief executive, Dara Khosrowshahi, to help right the ship.

Uber may see a lifeline in SoftBank. In recent weeks, the companies have been in discussions for SoftBank to take a large stake in Uber — in the neighborhood of 17 percent or more — with an investment of $10 billion, said the people close to the talks. The money would come from SoftBank’s so-called Vision Fund, a $100 billion fund that is used specifically to invest in technology start-ups across multiple industries.

Complicating the talks are the many strings attached to a potential deal. SoftBank is angling to invest in Uber at a steep discount to the company’s nearly $70 billion valuation. SoftBank has agreed to buy some new shares at the same valuation, but would also participate in a tender offer sent to existing Uber investors, in which the Japanese company could potentially buy their Uber shares at a price that is cheaper than the ride-hailing service’s last valuation.

For Uber, SoftBank could be a potentially powerful ally. SoftBank’s new capital could aid Uber’s expensive expansion efforts in regions like Southeast Asia and Latin America. The money could also go toward cashing out existing investors and employees, who have not been able to sell their stock since Uber is a privately held company.

If no agreement is reached, SoftBank could also pose a significant threat to Uber. In a meeting with Uber investors this week, Rajeev Misra, leader of SoftBank’s Vision Fund, said SoftBank would be willing to invest in a rival like Lyft if Uber did not agree to SoftBank’s terms, according to two people familiar with the conversation. Those terms included demands like the heavily discounted share price, and two seats on Uber’s board of directors.

Lyft’s recent fund-raising activities have also complicated the calculus for Uber. Lyft closed a $500 million financing round in April, with support from Kohlberg Kravis Roberts, the private equity firm.

More recently, Lyft has held talks with Alphabet for a new $1 billion investment, according to people familiar with the discussions. It is unclear what the status of those talks are, though the discussions appear to be driven by Larry Page, Alphabet’s chief executive, the people said.

Lyft could use any new funding to keep pressure on Uber in its most lucrative market, North America, by offering subsidized trips to riders.

An investment would also strengthen Lyft’s relationship with Alphabet, which has emerged as one of Uber’s most powerful foes. In May, Lyft reached a deal to work on a self-driving-vehicle pilot program with Waymo, Alphabet’s autonomous-vehicle subsidiary. Waymo sued Uber this year, claiming stolen trade secrets in driverless-car technology.

“Ride sharing is starting to look more like a business that will be regionally dominated by local duopolies and monopolies,” Mr. Garcia said. “Until the winners shake out, the companies will use money from the same investors to cannibalize one another.”