A New York man has pleaded guilty to sending death threats to the state attorney general and the Manhattan judge who presided over former President Donald Trump’s civil fraud case, prosecutors said Thursday.

Tyler Vogel, 26, of Lancaster, admitted to one felony count of making a terroristic threat and one misdemeanor count of making a threat of mass harm on Wednesday in state Supreme Court, according to Acting Erie County District Attorney Michael Keane’s office.

Vogel had sent text messages late last month threatening New York Attorney General Letitia James and Judge Arthur Engoron with “death and physical harm” if they did not comply with his demands to “cease action” in the Trump case, according to a complaint filed in a court in Lancaster, a suburb east of Buffalo.

State police said in the complaint that Vogel used a paid online background website to obtain private information about James and Engoron and that this “confirmed intentions to follow through with the threats were his demands not met.”

Keane's office said Thursday that Vogel, in entering the guilty plea, will be allowed to participate in interim probation and must comply with the mandates of state mental health court.

Once the court and probation requirements are completed, Vogel will be permitted to withdraw his plea to the felony charge and be sentenced on the misdemeanor charge, according to Keane's office.

He was released from custody and is due back in court April 23, but a temporary protection order issued on behalf of the two victims remains in effect, prosecutors said.

Vogel was initially charged with two felony counts of making a terroristic threat and two misdemeanor counts of aggravated harassment and faced a maximum of seven years in prison if convicted, prosecutors said at the time.

His lawyer didn’t respond to an email seeking comment Thursday and a spokesperson for James’ office declined to comment.

Trump, meanwhile, is again on trial in Manhattan this week.

The former Republican president, who is seeking a return to the White House in this year's election, faces 34 felony counts of falsifying business records as part of a scheme to bury stories about his sex life that he feared could hurt his 2016 campaign.

Trump has also appealed Engoron's Feb. 16 finding that he lied about his wealth as he fostered the real estate empire that launched him to stardom and the presidency.

The civil trial focused on how Trump’s assets were valued on financial statements that went to bankers and insurers to get loans and deals.