SAN FRANCISCO — For years, Uber spied on key executives, drivers and employees at rival ride-hailing companies as part of a larger intelligence-gathering operation that spanned multiple countries, according to a letter made public in a federal court Friday.The 37-page letter, written by Richard Jacobs, a former Uber security employee, detailed what he described as the formation of separate internal teams designed "expressly for the purpose of acquiring trade secrets" from major ride-sharing competitors around the world.Those teams then worked to infiltrate chat rooms and scraped websites for data on competitors, according to the letter. Uber security employees occasionally impersonated drivers to gain access to chat groups, illegally recorded phone calls, and secretly wiretapped and tailed executives at rival companies over the course of 2016, the letter said."Uber has engaged, and continues to engage, in illegal intelligence gathering on a global scale," Jacobs wrote.His letter underscores the lengths that Uber went to to get ahead of rivals under its former chief executive, Travis Kalanick, when it prized aggressiveness and the growth of its ride-hailing business above all else. The company is now trying to shift away from that image and stabilize after a year filled with scandals, executive departures and internal battles. Kalanick stepped down in June, and his successor, Dara Khosrowshahi, has been on an apology tour for Uber’s past behavior.Jacobs’ letter is part of a trade secrets case that Uber is fighting against Waymo, the self-driving automobile business that operates under Google’s parent company. Waymo has said Uber stole information about driverless-car technology from it. Uber has denied Waymo’s allegations, and the case is scheduled to go to trial next month.Jacobs’ letter surfaced last month when the U.S. attorney’s office in Northern California alerted the federal judge in the Uber-Waymo case to its existence. The letter was submitted into evidence because it also detailed allegations that Uber employees potentially conspired to steal trade secrets from Waymo. The judge, William Alsup of U.S. District Court in San Francisco, then delayed a trial in the case so Waymo’s lawyers could gather more information on the claims.At the time, Jacobs appeared in court about his letter. In his testimony, he walked back some of its claims, including those pertaining to Uber’s alleged theft of Waymo’s trade secrets. Uber had privately settled a lawsuit by Jacobs for millions of dollars this year.Jacobs’ letter said that after the Uber teams followed rival executives to hotels or private meeting spaces, they relayed their actions to Kalanick."While we haven’t substantiated all the claims in this letter — and, importantly, any related to Waymo — our new leadership has made clear that going forward we will compete honestly and fairly, on the strength of our ideas and technology," Matt Kallman, a spokesman for Uber, said in a statement after the letter’s release.Uber is facing at least five separate federal investigations, including at least one over a software tool called "Greyball," which the company created to evade law enforcement in cities around the world. It is also facing an investigation into whether the company broke the Foreign Corrupt Practices Act for bribery overseas, a claim Jacobs made in his letter.Two of Uber’s top security officials — Sullivan and Craig Clark, a lawyer on Sullivan’s team — were let go this month, after the company disclosed that it had covered up a 2016 hacking that affected the accounts of more than 50 million drivers and riders.On Friday, Sullivan and others on the security team disputed Jacobs’ letter, saying it was "nothing more than character assassination for cash," according to a statement from Matthew Umhofer, an attorney for four Uber security employees. "Jacobs took the good work my clients did and twisted it into something it wasn’t," Umhofer said.