SAN FRANCISCO (Reuters) - Uber Technologies Inc [UBER.UL] will pay $245 million worth of its own shares to Alphabet Inc’s Waymo self-driving vehicle unit to settle a legal dispute over trade secrets, allowing Uber’s chief executive to move past one of the company’s most bruising public controversies.

The settlement announcement on Friday brought an abrupt halt to the captivating case just before the fifth day of testimony was to begin at a jury trial in federal court in San Francisco.

In a lawsuit filed last year, Waymo said that one of its former engineers who became chief of Uber’s self-driving car project took with him thousands of confidential documents.

The lawsuit cost Uber precious time in its self-driving car ambition, which is a key to its long-term profitability. Uber fired its self-driving chief after Waymo sued, and it is well behind on its plans to deploy fleets of autonomous cars in one of the most lucrative races in Silicon Valley.

The settlement allows Uber’s chief executive officer, Dara Khosrowshahi, to put another scandal behind the company and move ahead with development of self-driving technology, following the tumultuous leadership by former CEO Travis Kalanick, who testified at the trial on Tuesday and Wednesday.

As part of the deal, Waymo gets a 0.34 percent stake in Uber, worth about $245 million based on Uber’s current $72 billion valuation, a Waymo representative said. The settlement includes an agreement to ensure that Waymo confidential information is not being incorporated into Uber technology, which Waymo has said was its main goal in bringing the lawsuit.

In settlement talks last year, Waymo had sought at least $1 billion from Uber, and wanted an independent monitor to ensure that Uber would not use Waymo technology in the future, Reuters reported. Waymo also asked for an apology. Uber rejected those terms as non-starters.

Waymo had agreed earlier this week to a settlement proposal valued at $500 million, and Khosrowshahi brought the proposal to the Uber board of directors, offering his support.

But Uber’s board rejected those terms on Tuesday, two sources familiar with the discussions said, sending Khosrowshahi and chief legal officer Tony West back to renegotiate.

In the interim, the famously pugnacious Kalanick testified in court, maintaining a calm demeanor as he answered questions about Uber’s soured relationship with Alphabet and his admiration for Anthony Levandowski, the self-driving-car engineer whose actions led to the lawsuit.

After four days of testimony, Waymo had presented little public evidence that Uber used Waymo’s trade secrets.

By late Thursday, Waymo agreed to the $245 million deal, one of the sources said.

In a statement on Friday, Khosrowshahi expressed “regret” for Uber’s actions.

“While we do not believe that any trade secrets made their way from Waymo to Uber, nor do we believe that Uber has used any of Waymo’s proprietary information in its self-driving technology, we are taking steps with Waymo to ensure our Lidar and software represents just our good work,” Khosrowshahi said in a statement.

Lidar is a light-based sensor crucial to autonomous driving.

Neither company offered details on what those steps will entail. Shares of Alphabet closed up 3.8 percent on Friday.

Elizabeth Rowe, a professor at the University of Florida Levin College of Law, analyzed about 150 trade secret verdicts through 2014 and said $245 million would rank as the second highest. Given that landscape, along with the fact that Alphabet CEO Larry Page could have had to testify next week, the settlement makes sense for Waymo, she said.

FILE PHOTO: Waymo unveils a self-driving Chrysler Pacifica minivan during the North American International Auto Show in Detroit, Michigan, U.S., January 8, 2017. REUTERS/Brendan McDermid/File Photo

“Their risks would have gone up on many levels,” Rowe said.

Waymo’s lawsuit said that Levandowski had downloaded more than 14,000 confidential files containing designs for autonomous vehicles in December 2015 before he went on to work at Uber in 2016.

The U.S. Department of Justice is conducting a separate, criminal investigation into the trade secrets. Levandowski has never publicly addressed the allegations of taking the documents and law enforcement has not charged anyone with their theft. Levandowski was not a defendant in the case.

SERIES OF PROBLEMS AT UBER

The Waymo lawsuit was the most pressing legal battle for Uber, but only one item in a long list of controversies that has dogged the company for the last year.

Public accusations of sexual harassment and a toxic workplace prompted an internal investigation at Uber that resulted in more than 20 people being fired, and the company faces multiple federal criminal probes. The company has also suffered from turmoil at the top with the ousting of Kalanick in June and a bitter board dispute.

Uber had planned to have self-driving cars in 20 cities by the end of 2018, 50 cities by 2019 and 150 by 2020, according to documents shown in court. It is far from achieving those ambitions.

Uber now has small pilots in Tempe, Arizona, and Pittsburgh, Pennsylvania. Although it has acquired the necessary California permit, it still does not have self-driving cars transporting passengers there.

The settlement increases Alphabet’s stake in Uber from an initial investment of $258 million in 2013, which at the time was Uber’s largest fundraising round.

Uber has gone on to raise more than $14 billion in new funding and last month closed a deal with SoftBank Group Corp, in which the Japanese conglomerate, along with other investors, took about a 17.5 percent stake in the company. SoftBank bought the majority of its stake at about a 30 percent discount from Uber’s valuation.

Autonomous cars offer a multi-billion-dollar opportunity to remake urban transportation systems, and companies including Apple Inc, General Motors Co and scores of startups are competing to develop the technology.

To prevail in the trial, Waymo would have had to prove not only that Uber acquired Waymo’s trade secrets, but that it used them in its own technology.

Kalanick in a statement on Friday said the path to victory was clear: Uber’s sole objective was to hire the most talented scientists and engineers and it had never possessed trade secrets.

“Had the trial proceeded to its conclusion, it is clear Uber would have prevailed,” Kalanick said.