When Donald J. Trump met Stormy Daniels, their flirtation seemed fleeting: He was a 60-year-old married mogul at the peak of reality television fame, and she was 27, a Louisiana native raised in poverty and headed to porn-film stardom.

But that chance encounter in Lake Tahoe, Nev., some two decades ago is now at the center of the first criminal trial of an American president, an unprecedented case that could shape the 2024 presidential race.

This week, Ms. Daniels has been on the witness stand telling her side of the story, often in explicit detail. She has already faced five hours of questioning, and after the trial’s midweek hiatus, she is expected to return on Thursday to undergo additional cross-examination from Mr. Trump’s legal team.

The charges against Mr. Trump stem from her story of sex with him during that 2006 celebrity golf tournament in Lake Tahoe, a story she was shopping a decade later, in the closing days of the presidential campaign. Mr. Trump’s longtime lawyer and fixer, Michael D. Cohen, paid Ms. Daniels $130,000 in hush money before Election Day, and the former president is accused of falsifying business records to cover up reimbursements for Mr. Cohen.

On Tuesday, Ms. Daniels’s fast-paced testimony lasted nearly five hours, during which she described an encounter with Mr. Trump, now 77, that he has long denied. Tension gripped the courtroom, her voluble testimony filling a heavy silence. She made jokes; they did not land.