Donald J. Trump, who has weathered two impeachment trials, a special counsel inquiry and decades of investigations, was accused by Manhattan prosecutors on Tuesday of orchestrating a hush-money scheme to pave his path to the presidency and then covering it up from the White House.

Mr. Trump pleaded not guilty in the case, which has far-reaching political consequences and opens a perilous chapter in the long public life of the real estate mogul and former president, who now faces the embarrassing prospect of a criminal trial.

Mr. Trump, who was indicted on 34 felony counts and stands accused of covering up a potential sex scandal involving a porn star, made an extraordinary appearance at the Criminal Courts Building in Lower Manhattan to face the charges. Even as Mr. Trump’s supporters rallied outside, the former president sat, almost docile, at the defense table, listening as prosecutors described the case against him.

Overall he said fewer than a dozen words, but at one point leaned forward and entered his plea of “not guilty” in the packed but pin-drop-quiet courtroom, a surreal scene for a man who months ago mounted a third run for the White House.

The hearing was also momentous for the prosecutor who brought the case, the Manhattan district attorney, Alvin L. Bragg. Afterward, he made his first remarks since the indictment, punctuating a proceeding that gave his liberal Manhattan base a long-awaited moment of catharsis: Mr. Trump’s first day in court as a criminal defendant.

“Everyone stands equal under the law,” Mr. Bragg, a Democrat, said at a press conference after the arraignment. “No amount of money and no amount of power” changes that, he added.

During the hearing, one of the prosecutors from the Manhattan district attorney’s office, Chris Conroy, brought up threatening posts that Mr. Trump has made online in past weeks, including writing that “death and destruction” would follow if he were to be charged.

In response, the judge overseeing the case, Juan M. Merchan, addressed Mr. Trump’s lawyers, telling them, “Please speak to your client and anybody else you need to, and remind them to please refrain from making statements that are likely to incite violence or civil unrest.”

The case, brought in Mr. Trump’s hometown, is the beginning of the former president’s journey through the criminal justice system. That journey may not end in New York: He faces three other criminal investigations — in Georgia and Washington — related to accusations of undermining an election and mishandling sensitive government records, issues at the core of American democracy and security.

But Mr. Trump’s election in 2016 also accelerated a circuslike era in American politics, marked by fiery social media posts and an at-best casual relationship with the truth. And now, perhaps fittingly, the first criminal case against Mr. Trump accuses him of lying to cover up a tryst with a porn star: a tabloid indictment for a tabloid president.

With the charges now unsealed, the public can delve deeper into the details of a tawdry tale of sex, lies and intrigue that seems to have sprung from a gossip column and ended up in a felony indictment. The central players in the case are a stranger-than-fiction trio: the porn star, the hangdog fixer who paid her off and the former president who stands accused of trying to cover the whole thing up.

The hearing inaugurated a new era of Mr. Bragg’s tenure — he will occupy the national stage for months to come — even as the case opens him up to criticism from Mr. Trump’s supporters, who charge that he has blindly pursued the former president.

For Mr. Bragg, securing a conviction is no sure thing. He accused Mr. Trump of falsifying business records related to the hush money, felony charges that appear to hinge on a novel application of the law.

After returning to Florida on Tuesday, just hours after Justice Merchan cautioned him against incendiary rhetoric, Mr. Trump lashed out at Mr. Bragg, the judge and their families during a meandering rally-style speech before supporters at Mar-a-Lago, his Palm Beach estate.

Mr. Trump vented grievances about the other investigations still swirling around him. When he turned to the Manhattan case, he lashed out at Mr. Bragg and his wife as well as Justice Merchan — whom he called “Trump-hating” — and also attacked the judge’s wife.

Mr. Trump has repeatedly assailed Mr. Bragg, who is Black, with racist language and made threatening statements reminiscent of his posts in the run-up to the attack on the U.S. Capitol on Jan. 6, 2021.

Mr. Trump was accompanied in court by his legal adviser, Boris Epshteyn, and the lawyers handling this case, Todd W. Blanche, Susan R. Necheles and Joseph Tacopina.

Mr. Blanche, speaking outside the courthouse after the arraignment, said the former president was determined to prevail. “He’s frustrated. He’s upset. But I will tell you what. He is motivated. It’s not going to slow him down,” he said.

The charges against Mr. Trump trace to a $130,000 hush-money payment that his fixer, Michael D. Cohen, made to the porn star, Stormy Daniels, in the final days of the 2016 campaign. The payment, which Mr. Cohen said he made at Mr. Trump’s direction, suppressed her story of a sexual liaison with Mr. Trump.

While serving as the commander in chief, Mr. Trump reimbursed Mr. Cohen, and that’s where the fraud kicked in, prosecutors say. In internal records, Mr. Trump’s company falsely classified the repayment to Mr. Cohen as legal expenses, citing a retainer agreement. Yet there were no such expenses, the prosecutors say, and the retainer agreement was fictional as well.

Those bogus records underpin the 34 counts of falsifying business records: 11 counts involve the checks, 11 the monthly invoices Mr. Cohen submitted to the company, and 12 the entries in Mr. Trump’s general ledger. And to link Mr. Trump to those false records, prosecutors cited an Oval Office meeting between Mr. Trump and Mr. Cohen during which they “confirmed this repayment arrangement.”

While the charges focus on the payoff to Ms. Daniels, Mr. Bragg’s prosecutors also accused the former president of orchestrating a broader scheme to influence the 2016 presidential election by purchasing damaging stories about him to keep them under wraps.

Along with the indictment, the prosecutors filed a so-called statement of facts, which is common in complex white-collar cases. The document, which provides something of a road map for the evidence that prosecutors could reveal at trial, details two other hush-money deals involving The National Enquirer, which has longstanding ties to Mr. Trump.

The first deal involved a $30,000 payment the tabloid made to a former Trump Tower doorman who claimed to know that Mr. Trump had fathered a child out of wedlock. The publication later determined the claim was untrue.

The National Enquirer then made another payment to Karen McDougal, Playboy’s playmate of the year in 1998, who wanted to sell her story of an affair with Mr. Trump during the 2016 campaign. She reached a $150,000 agreement with The Enquirer, which bought the rights to her story to suppress it — a practice known as “catch and kill.”

Mr. Trump has denied having affairs with Ms. McDougal and Ms. Daniels.

His arraignment, the product of a nearly five-year investigation, kicks off a volatile new phase of his post-presidential life, setting up a split-screen battle on the campaign trail and in the courtroom. And it will throw the race for the Republican nomination — which he is leading in most polls — into uncharted territory.

For weeks, Mr. Trump has alternately fretted and blustered about the prospect of an arrest, while his aides have leveraged the indictment to ramp up fund-raising and push primary rivals into an awkward position somewhere between criticizing prosecutors and backing Mr. Trump. The case will also test Mr. Trump’s sway over his party — a hold so strong that he once predicted that he could shoot someone on Fifth Avenue and not lose any supporters.

Mr. Trump is highly unlikely to plead guilty down the road, and any trial is some months off, raising the possibility of its unfolding in the thick of the 2024 presidential campaign.

It remains unclear whether he would face prison time. At most, falsifying business records amounts to a low-level felony that carries a maximum of four year in prison for each count, though a judge could sentence Mr. Trump to probation.

Charges of falsifying business records qualify as a felony, rather than a misdemeanor, only if Mr. Trump’s “intent to defraud” included an effort to commit or conceal a second crime. It is unclear whether Mr. Bragg has settled on the specifics of that second crime; in his news conference he mentioned a number of potential underlying crimes, most prominently a violation of a state election law that bars any conspiracy to promote “the election of a person to public office by unlawful means.”

Under this theory, the state’s election laws were violated because the $130,000 payoff was an improper and unrecorded donation to Mr. Trump’s campaign, silencing Ms. Daniels and shutting down a potential sex scandal in the final stretch of the campaign.

Yet that legal strategy carries some challenges for Mr. Bragg. Never before has a New York prosecutor brought an election-law case involving a federal election, a New York Times analysis has found. And bringing an untested case against anyone, let alone a former president, raises the risk that a judge or appeals court could dismiss or narrow the case.

At the arraignment, Mr. Trump’s lawyers began to attack Mr. Cohen, the prosecution’s star witness, questioning his credibility and whether he has an ax to grind against Mr. Trump. Mr. Cohen has said he is not seeking revenge, but rather wants to hold his former boss “accountable for his dirty deeds.”

The arraignment came in the midst of a chaotic day outside the courthouse. As helicopters circled overhead, the streets were crammed with the press corps and hundreds of demonstrators, with the former president’s supporters and critics assembling at a nearby park, where they screamed at each other from across metal police barricades placed to keep the peace.

With the Secret Service in tow, Mr. Trump was fingerprinted and escorted through the Art Deco courthouse after surrendering to investigators at the Manhattan district attorney’s office in the morning. But special accommodations were made for the former president: He spent only a short time in custody and he was not handcuffed, nor was a booking photo taken.

The former president has spent many years fending off criminal charges. He was first investigated in New York in the late 1970s, an episode that set the tone for how he dealt with prosecutors, including Robert S. Mueller III’s special counsel inquiry into his campaign’s ties to Russia.

The hush-money episode burst into public view a year into Mr. Trump’s presidency when The Wall Street Journal reported on the deal between Mr. Cohen and Ms. Daniels. In the summer of 2018, Mr. Cohen pleaded guilty to federal campaign finance charges related to the payment and accused Mr. Trump of directing him to make it. Those prosecutors never charged Mr. Trump but revealed in court papers that Mr. Cohen acted “in coordination with and at the direction of” Mr. Trump.

Mr. Cohen’s case spurred the then-district attorney, Cyrus R. Vance Jr., to open his own investigation into the then-president and his business, the Trump Organization. But Mr. Vance’s inquiry expanded to focus on Mr. Trump’s business practices, including whether he fraudulently inflated his net worth.

Mr. Vance did not run for re-election, and he left office at the end of 2021. His successor, Mr. Bragg, inherited the case, but soon grew concerned about whether they could prove it. Weeks into his tenure, Mr. Bragg halted the presentation before the grand jury, prompting the resignation of two senior prosecutors and a public uproar in liberal Manhattan.

Yet Mr. Bragg continued the investigation, and by summer, his prosecutors had returned to the hush-money payment. In January, they impaneled a new grand jury.

The first witness was David Pecker, the former publisher of The National Enquirer, the tabloid that helped broker the deal between Mr. Cohen and Ms. Daniels and bought the stories of the doorman and Playboy model.

For prosecutors, Mr. Pecker was key to corroborating important aspects of Mr. Cohen’s story. Mr. Pecker visited Mr. Trump at Trump Tower in 2015 and agreed to be the then-candidate’s “eyes and ears” for stories that might harm his nascent campaign.

That meeting could help prosecutors show that Mr. Trump intended to stifle damaging stories to protect his campaign, not just to spare his family embarrassment, as his lawyers contend.

After hearing from Mr. Pecker a second time, along with at least eight other witnesses, including Mr. Cohen, the grand jury voted last week to indict.

Reporting was contributed by Kate Christobek, Sean Piccoli, Nate Schweber, Jason Silverstein, Chelsia Rose Marcius, Hurubie Meko and Lola Fadulu.