A North Carolina man who commandeered a Washington pizza restaurant with an assault-style rifle in December pleaded guilty Friday to weapons and assault charges in a deal with U.S. prosecutors.

Edgar Maddison Welch, 28, admitted traveling to the District anticipating a violent confrontation over his personal investigation of a viral Internet rumor known as “Pizzagate,” an unfounded conspiracy theory that linked Hillary Clinton to an alleged child-sex-trafficking ring. The false stories said the ring operated in the basement of Comet Ping Pong, where Clinton’s presidential campaign chairman, John Podesta, occasionally dined.

In a case that drew national headlines, Welch, who is from Salisbury, N.C., showed up at the popular restaurant on a Sunday afternoon, carrying a fully loaded AR-15 rifle and revolver in plain view. He pleaded guilty to a federal charge of transporting firearms and ammunition across state lines and a District count of assault with a dangerous weapon.

At Friday’s hearing, U.S. District Judge Ketanji Brown Jackson of Washington asked Welch: “Did you in fact transport these firearms from North Carolina to the District of Columbia and . . . enter the Comet Ping Pong restaurant openly carrying [an AR-15 rifle] and point it in the direction of a person?”

“Yes ma’am,” Welch, wearing eyeglasses, a beard and an orange jail shirt and pants, said during a series of brief answers to the judge.

Each count carries a maximum statutory penalty of 10 years in prison, but prosecutors and Welch’s federal defender agreed that nonbinding guidelines would probably call for a federal sentence of 18 to 24 months and a District penalty of 18 to 60 months, which could run consecutively. The sides did not agree on a sentencing recommendation.

Welch agreed to forfeit the rifle, revolver, a shotgun and ammunition he carried with him that day and to pay restitution of $5,744.33 to the restaurant for damaged computer systems, a door, lock and ping-pong table.

Prosecutors agreed to drop a District charge of possessing a firearm while committing a crime of violence, which carried a 15-year maximum penalty.

Welch will remain jailed until sentencing, which Jackson set for June 22.

Also Friday, conservative radio host and Infowars website operator Alex Jones apologized for promoting the Pizzagate conspiracy. Jones posted a ­six-minute video on his website in which he read a prepared statement stating that neither the restaurant nor its owner, James Alefantis, had anything to do with human trafficking. The statement came after Alefantis’s attorneys had requested a retraction.

“In our commentary about what had become known as ­Pizzagate, I made comments about Mr. Alefantis that in hindsight I regret, and for which I apologize to him,” Jones said. “We apologize to the extent our commentaries could be considered as negative statements about Mr. Alefantis or Comet Ping Pong, and we hope that anyone else involved in commenting on ­Pizzagate will do the same thing.”

In plea papers, Welch, a father to two young girls, acknowledged that he had become agitated by reports and videos he read and saw online about the supposed sex ring. Welch drove to Washington in a Toyota Prius on Dec. 4.

“The defendant then took it upon himself to act in what he believed would be a violent confrontation at the restaurant,” assistant U.S. attorneys Demian S. Ahn and Sonali D. Patel wrote, drawing from text messages and other information captured on Welch’s cellphone as he unsuccessfully tried to recruit friends for what he said could be a one-way mission.

“Raiding a pedo ring, possible [sic] sacrificing the lives of a few for the lives of many,” Welch wrote in one text. He continued: “Standing up against a corrupt system that kidnaps, tortures and rapes ­babies and children in our own back yard.”

Shortly before 3 p.m., Welch parked and left a loaded 12-gauge shotgun and box of shells in the car, he admitted in plea papers.

Welch acknowledged walking into the restaurant carrying a fully loaded, six-shot .38-caliber Colt revolver on his hip, and holding the 9mm AR-15 Colt rifle with about 29 rounds of ammunition across his chest, with his hands on the pistol-style grip and around the barrel.

After a panicky evacuation by workers and customers, including children, Welch fired the rifle multiple times at a locked closet door, striking computer equipment inside, court documents said. He also pointed the rifle toward an unwitting employee retrieving pizza dough from a nearby business who entered the back of the restaurant, then immediately turned and ran for his life, according to the government’s evidence signed off by Welch.

Welch ultimately did not shoot anyone and surrendered after he found no evidence of hidden rooms or sex trafficking. Friends and family members had said they thought Welch was on a mission to save children, not to hurt anybody.

Dana Hedgpeth contributed to this report.