SAN FRANCISCO — For nearly a year, Uber and Google's parent company, Alphabet, clashed over settling a lawsuit Alphabet filed against the ride-sharing company, according to two people familiar with the discussions.

Uber chose to gamble for a victory in court rather than compromise, a choice that led to a high-stakes public trial last week.

Negotiations went right up to the trial itself. As recently as last week, Uber’s board had rejected a settlement offer.

Yet on Friday, just as journalists were settling into the packed courtroom after days of bruising testimony, Uber announced it was settling the case. The agreement gave Alphabet’s self-driving car business Waymo a stake worth $244 million in the world’s most valuable privately held start-up — and the right to vet Uber's self-driving technology.

The sudden settlement is the most striking example of Uber’s new lower-risk approach under chief executive Dara Khosrowshahi — a reversal from his predecessor, Travis Kalanick, whose brash and confrontational strategy brought rapid growth and defined start-up culture but also triggered years of conflict with regulators, shareholders, drivers and employees.

Since he became chief executive last August, Khosrowshahi has been steadily putting out fires from the Kalanick era, a strategy of de-risking the business ahead of a public offering in 2019. He has shuttered or made compromises to end controversial parts of Uber's businesses. In December, Uber said it would sell its money-losing U.S. auto-leasing business. This week, the company announced that it would mandate that drivers take six-hour breaks, a concession to rival taxi commissions, which have similar rules. In London, he is working behind the scenes to restore the company's recently-revoked license to operate.

In announcing the settlement to the lawsuit Friday morning, Khosrowshahi addressed Uber’s “friends at Alphabet.” Google’s parent company, in the lawsuit filed last February, had accused Uber of stealing its trade secrets and using them in its own self-driving car technology.

A loss would have been “devastating,” for Uber, valued at $72 billion according to its most recent round, said Shubha Ghosh, director of the Technology Commercialization Law Center at Syracuse University’s College of Law. Alphabet was seeking damages of $1 billion.

Khosrowshahi wasn’t willing to take the risk of losing the lawsuit. “A settlement leaves matters more ambiguous for Uber and gives the company some cover,” Ghosh said. Khosrowshahi doesn’t want to stay mired in fights that drag Uber down, say people who work with him. He has said he plans for Uber to have a public offering next year.

“Companies at different phases need different kinds of leadership,” said Paul Saffo, a futurist who teaches technology forecasting at Stanford University. “Without a doubt, Kalanick’s relentless drive brought Uber to where it is now, but at some point that energy can become a liability once you’ve arrived. This is a company that now has adult supervision and understands that it needs to pay attention to its shareholders.”

Among themselves, some Uber employees refer to the new chief executive as “the anti-Kalanick,” according to two employees. Many respected Kalanick because he had gotten Uber to a level that the company would not have reached otherwise, if only for his sheer willingness to flout local rules that either prohibited or were vague about ride-sharing. But in the last year, in particular, many felt that Kalanick was hurting Uber more than helping and that some of the company’s problems were self-inflicted. These included getting into a yelling match with an Uber driver who complained about wages for drivers and covering up a major security breach of stolen driver and rider data.

But, Saffo cautioned, Uber faces a serious challenge as it transitions from a company with start-up momentum to one led by professional management. Early on, Saffo said, employees work exceptionally hard because they know their management is working even harder and has even more at stake than they do. An appearance of rapid growth also attracts workers looking for a big payday when the company goes public.

Legal experts and insiders said the two parties had little to gain from an ugly and drawn-out court fight. Both would come out looking bad, no matter who won. Uber’s self-driving engineers “had been distracted from your mission” by the case, Khosrowshahi said.

As the week went on, exposing internal communications to the public and generating a daily flurry of sensational headlines, the outcome was very much a matter of debate.

Uber and Alphabet began court-mandated settlement discussions shortly after Alphabet filed the lawsuit in early 2017, according to a person familiar with the discussions.

But the relationship between Kalanick and Alphabet chief executive Larry Page had soured, Kalanick said at trial. Uber's board ousted Kalanick in June, and subsequent leadership vacancies complicated the situation further.

When Uber’s board unexpectedly poached Khosrowshahi, formerly chief executive of Expedia, for the top job at Uber, he was relatively unknown outside of a small circle of Silicon Valley executives. But those who knew him, including former regulators, praised his mature decision-making and ability to cut deals. He had a full roster of crises demanding his attention, from the lawsuit to the London suspension and the data breach.

One of Khosrowshahi’s first acts as chief executive was to introduce a new set of eight corporate principles, which included owning up to past mistakes and doing the “right thing — period.” (Kalanick had enshrined “toe-stepping” and “always be hustlin'.”) Khosrowshahi traveled to Europe, where he conducted a listening tour and ensured regulators that the company was opening a new chapter.

In October, Tony West, a former Justice Department official, filled Uber’s vacant general counsel seat. Soon after, he and Khosrowshahi reached out to Alphabet’s leadership to let them know that they hoped to restart negotiations in good faith, according to a person familiar with the company’s thinking.

Those conversations continued up until last week, when Uber’s board rejected a settlement offer of $500 million that would have included more equity for Waymo, according to people familiar with the discussions.

West and his counterpart at Waymo, Kevin Vosen, kept a backchannel open and ultimately came to an agreement Thursday night. The amount was 0.34 percent of Uber’s equity, with Waymo being allowed some visibility, through a third party company, into Uber's self-driving hardware and software.

Even after the settlement was announced, Kalanick seemed unwilling to give up the fight. Had the trial proceeded to its conclusion, he said in a statement, “it is clear Uber would have prevailed.”

Khosrowshahi’s attitude has already shifted morale for some employees. “For you to grow and improve, whether it's a person or company, you got to face the problems you have in a clear and honest way,” said Wayne Ting, Khosrowshahi’s chief of staff and the general manager of the northern California region under Kalanick. “To me, it felt like we had to make a real change in the tone at the top.”