Two weeks ago, Google had a big day in Washington. President Biden signed an executive order to create artificial intelligence safeguards that could affect Google’s most pressing projects, and Secretary of State Antony J. Blinken gave the company an award for its work in aiding Ukrainian refugees and promoting women’s economic security.

Sundar Pichai, Google’s chief executive, had spent much of the day on a witness stand at a federal courthouse about two miles from the White House, defending his company from claims that it crushed rivals in the search and online advertising markets.

On Tuesday, Mr. Pichai is expected to testify again, this time in San Francisco, to confront claims brought by the video game company Epic Games that his company broke the law, wielding monopolistic power over app developers on Android’s Google Play Store.

Mr. Pichai over the last month has become the face of Google’s antitrust court fights on both sides of the country. And his visits to the witness stand underscore the growing importance for Big Tech leaders to be sharp witnesses for their companies, whether in an antitrust trial or in hearings on Capitol Hill.

Testifying under oath is a task that many tech chief executives might be asked to do in the coming years, with Amazon, Meta and others facing their own antitrust court fights. It is not a task at which many executives have excelled.

Though he was never called to the witness stand to testify, Bill Gates, who was chief executive of Microsoft in the last big technology antitrust case brought by the Justice Department more than two decades ago, came across as combative and evasive in depositions.

Over the last few years, executives including Mark Zuckerberg and OpenAI’s Sam Altman (and, of course, Mr. Pichai) have been asked to testify before Congress for various reasons, with varying degrees of success. Mr. Zuckerberg has at times exasperated lawmakers with vague responses, while Mr. Altman appeared to charm senators in a hearing this year.

The main duty on the witness stand for Mr. Pichai — a low-key and detail-focused executive — has been to keep the temperature low under questioning and keep to the central point of Google’s antitrust defense: that it is an innovative company that has maintained its leadership through innovation and hard work instead of illegal monopolistic behavior.

The Justice Department filed its landmark antitrust suit against Google in October 2020, arguing that the company’s default-search deals with phone makers and browser companies helped it illegally maintain a monopoly.

Google called Mr. Pichai, 51, to the stand two weeks ago. Rather than sit in the witness box, Mr. Pichai stood at a lectern for almost four hours, wearing a microphone, as though he were delivering a speech at a corporate conference. His handlers said he had to stand because of a sprained lower back.

He spoke of his background, getting a telephone as a preteen in Chennai, India, and understanding then the power of technology, before he deftly answered questions about his company’s competitive standing, relationship with Apple and the default-search contracts the government argues were illegal.

Mr. Pichai tried to refute the government lawyer’s arguments that Google paid Apple billions of dollars a year to keep it out of the search market. He presented a different story, saying his company wanted to be the iPhone’s default search engine because of the “value” of that spot, and the need to ensure Apple would safeguard the user experience.

“I felt the deal had done well since 2016,” Mr. Pichai said. “It was continuing to increase search usage, search revenue.”

In cross-examination, Mr. Pichai repeated the rationale for the deal so many times that for a moment, he seemed to lose patience with the line of questioning, saying, “I just gave all the reasons” for the deal.

Adam Kovacevich, a tech industry lobbyist at the Chamber of Progress who spent 12 years working at Google, said Mr. Pichai’s testimony gave the court a high-level view of how the company made strategic decisions.

“He did fine,” Mr. Kovacevich said of Mr. Pichai’s performance. “The biggest thing to me is when you’re in that position, your first objective is to not be Bill Gates in the Microsoft trial. Your No. 1 objective is to come off as responsive and reasonable.”

Excerpts from Mr. Gates’s combative, videotaped testimony were shown in court more than two decades ago. The Microsoft co-founder, antitrust lawyers say, undermined his and his company’s credibility with the judge in the case.

In San Francisco, Mr. Pichai is expected to discuss the fierce competition between the operating systems of Apple’s iPhone and Google’s Android, to undercut Epic’s argument that Google’s app store practices are monopolistic. The chief executive was heavily involved in launching Android and is expected to share his view that the Play Store has helped many developers expand their businesses and enabled consumers to safely download apps.

There will be one big difference: The antitrust trial in Washington does not have a jury. The decision will be made by a judge. In San Francisco, Mr. Pichai will have to appeal to a jury that could be open to the idea that a giant tech company is exploiting much smaller outfits. Tim Sweeney, Epic’s chief executive, is also expected to testify in the trial.

Google and Epic declined to comment.

Epic, the maker of the hit game Fortnite, brought the claim against Google in 2020, in an attempt to sidestep the 15 to 30 percent fees from subscriptions and in-app purchases that it must pay Google.

The game developer antagonized Google and Apple by telling users to pay for in-app transactions directly through Epic. In response, Google and Apple suspended Fortnite from their app stores. Epic claims Google also bullied other companies to force them to drop deals with Epic before it was banned from the app stores.

Google faces another Justice Department antitrust lawsuit that accuses it of illegally abusing its monopoly power over the technology that delivers ads online.

A trial in that case could begin as soon as next year, but it is too early to know whether Mr. Pichai will be called to testify.

Mr. Pichai has tried to prevent Google employees from being distracted by the litigation. He has encouraged them to “keep doing what you’re doing” and has allocated a relatively small number of employees to work on the Justice Department case — hundreds out of more than 180,000.

But Mr. Pichai’s court appearances have taken time away from his other obligations as a company leader, including his plan to reclaim Google’s primacy in the fast-growing field of generative A.I.

In the middle of Mr. Pichai’s October testimony, the secretary of state, Mr. Blinken, was honoring Google’s subsidiary in Poland for its work in fostering women’s economic security and helping Ukrainian refugees. Hours later, Mr. Biden hosted a signing ceremony at the White House, but Mr. Pichai’s handlers could not R.S.V.P. yes because there was a chance he might have still been in court when it began.

“It’s not the best use of his time,” Richard Kramer, an analyst at Arete Research, a London-based investment research firm, said in an interview. “No C.E.O. wishes to spend their time being grilled by government lawyers.”