After turns as a real estate magnate, a New York tabloid mainstay, a reality TV star and president of the United States, Donald Trump is settling into a new role: defendant.

The front-runner for the Republican presidential nomination spent two days this week in a Manhattan courtroom where a civil fraud trial is unfolding. Trump is accused of grossly inflating his net worth and the value of marquee assets on paperwork used to secure financing and make deals.

In the courtroom, Trump is often subdued, sitting between his lawyers and staring straight ahead with a scowl as he studiously ignores his adversary, New York Attorney General Letitia James. But when he steps into the hallway where a phalanx of TV cameras awaits, Trump transforms into his familiar political persona, eager to spin the proceedings in his favor.

"If I wasn't here, probably — maybe — people wouldn't see the facts the way they are," Trump said during one of his swings before the cameras on Wednesday.

Trump, who also attended portions of the civil trial earlier this month, is under no legal obligation to attend the proceedings. But in a preview of how he'll likely approach the more serious criminal trials that will begin in the coming months, Trump uses the appearances as an extension of his presidential campaign, betting he can shape perceptions and portray himself as a political leader under attack.

The strategy has helped energize his supporters — and fill his campaign coffers — by casting his legal troubles as part of a broad conspiracy to deny him the presidency and rob him of the real estate empire he spent decades building. But it's also testing the limits of Trump's ability to harness his showmanship in a way that bends political and legal realities.

Trump was fined $5,000 on Friday after a copy of a social media post in which he disparaged a key court staffer was discovered on his campaign website long after he was ordered to delete it.

And during the same week that Trump was largely focused on New York, his legal vulnerabilities intensified elsewhere. In Washington, a federal judge imposed a limited gag order barring Trump from making statements targeting prosecutors, possible witnesses and court staff. For someone who sees few limits in attacking his perceived enemies, that order may be tested soon.

And in Georgia, lawyer Sidney Powell pleaded guilty Thursday to reduced charges over efforts to overturn Trump's 2020 loss in the state. Kenneth Chesebro, a lawyer accused of coordinating a slate of false electors to vote for the former president, pleaded guilty Friday.

The deals with Atlanta prosecutors could heighten Trump's legal exposure there if Powell agrees to testify against the former president.

On top of that, Trump was overshadowed by the escalating war between Israel and Hamas as well as the failure of Republicans to elect a new speaker of the House. While Trump's initial appearances drew a media maelstrom, with cable news networks airing live footage of his motorcade journey, this week's have drawn far less attention.

There have been fewer reporters and more empty seats in the courtroom gallery as news outlets have pulled back on covering his courthouse sojourns because the novelty has worn off. Unaccustomed to losing the spotlight, Trump acknowledged the challenge Tuesday.

"Despite my being here, the talk is all about Biden getting ready to fly to the Middle East to see Abbas, meeting arranged, and Abbas just cancelled," he wrote on his social media platform. "No respect for the United States of America!"

His public mood shifted throughout his time at the trial. He emerged from the courtroom elated on some days, predicting at one point that 80% of the $250 million fraud case would be thrown out because the judge had been receptive to an argument by his lawyers.

Other times he has come out fuming, like on Wednesday when he accused the government of lying after one of his lawyers alleged a witness had perjured himself. Again and again, he casts the proceedings as "rigged," a "disgrace" and part of a broader plot by Democrats to hobble his chances.

"I should be in Iowa now. I should be in New Hampshire now. I should be in South Carolina now or someplace else, campaigning," Trump complained Tuesday.

In the courtroom, he'll lean in occasionally to confer with counsel and follow along with a live transcript of the proceedings on a screen in front of him. Sometimes he'll flip through a pile of papers or react to testimony with a grimace or other expression.

On Wednesday, Judge Arthur Engoron warned Trump and others involved in the case to keep their voices down after he conferred animatedly with his lawyers at the defense table while a witness was testifying against him.

Trump threw up his hands in frustration and grumbled to his lawyers, prompting state lawyer Kevin Wallace to ask Engoron to ask the defense to "stop commenting during the witness' testimony," adding that the "exhortations" were audible on the witness' side of the room. The judge then asked everyone to keep their voices down, "particularly if it's meant to influence the testimony."

Otherwise, Trump has shown unusual restraint for a man who's used to being the center of attention, able to say and do as he pleases.

Aside from the historic nature of having a former president and current candidate at the defense table, Trump is something of a non-factor in the courtroom itself — typically seen, but not heard. The most unusual aspect of his attendance is often the moment when a small pool of photographers and video cameras parades into the room for a few minutes to capture the scene for posterity before testimony begins. It's a spectacle, with photographers jostling for position between the defense table and the judge's bench — with all eyes on the commotion.

While Trump's appearances in New York over the last few weeks have been purely voluntary, that will change as the civil case continues and his four criminal cases move toward trial. The former president will be required to return to New York to testify in his civil trial, likely in a few weeks. His lawyers have already told the judge he'll be unavailable for several days around the Nov. 7 off-year election.

Trump isn't required to be in court for writer E. Jean Carroll's second defamation trial against him — he teased an appearance at the first one before passing — but the case could still steal some headlines because it's scheduled to start on Jan. 15, 2024, the same day as the Iowa caucuses that kick off the GOP nomination process.

On Feb. 15, Trump will have to appear in person in New York ahead of a criminal trial on charges that he misclassified reimbursements for hush-money payments made to women during his 2016 campaign. His federal trial in Washington on charges related to his efforts to overturn the 2020 election is tentatively set to begin March 4 — the day before Super Tuesday contests — while his New York trial is set to begin weeks later on March 25.

His trial in Florida over his refusal to return classified documents stashed at his Mar-a-Lago club is set to begin May 20, while his trial in Georgia over his efforts to subvert the results of the state's 2020 election hasn't yet been scheduled.

Defendants in criminal trials generally must be present for large parts of their trials.

The judge in the hush-money case, Juan Manuel Merchan, has acknowledged the "huge undertaking" in getting Trump to court. But he warned that once the trial starts, he's obligated to be there and can't, for instance, "agree to any appearances, commitments, speaking engagements, anything of that kind."

Michael R. Sisak and Jill Colvin report for the Associated Press. AP writer Jennifer Peltz contributed to this report.

Copyright 2023 AP. All rights reserved. This material may not be published, broadcast, rewritten, or redistributed.