Edgar Maddison Welch, 28, of Salisbury, N.C., surrenders to police Dec. 4 in Washington. (Sathi Soma/AP)

The North Carolina man who commandeered a pizza restaurant at gunpoint in Northwest Washington to investigate a false Internet rumor of a pedophile ring there was sentenced to four years in in prison Thursday.

Edgar Maddison Welch, 28, who apologized to his victims and residents in the nation’s capital last week in a court filing, asked for an 18-month sentence for charging into Comet Ping Pong last December carrying a fully loaded AR-15 military-style rifle and revolver seeking to investigate a viral Internet rumor known as “Pizzagate.”

Prosecutors had sought a 4½ -year prison term.

False stories propagated a conspiracy theory that linked Hillary Clinton to an alleged child-sex-trafficking ring run from the family restaurant, where Clinton’s presidential campaign chairman, John Podesta, occasionally dined.

During the sentencing hearing, assistant U.S. attorneys Demian S. Ahn held up the rifle used by Welch and told the judge it had been part of an “armed invasion” and part of a campaign of “vicious harassment and unfounded rumors.”

(The U.S. Attorney's Office for the District of Columbia)

James Alefantis, who owns Comet Ping Pong also appeared in court saying the “physical terror” created by Welch and the rumors “left lasting damage on the people I love” adding that he hoped that “one day in a more truthful time we will remember this day as an aberration” when “lies were seen as real and our social fabric had frayed.”

Welch pleaded guilty in March to a District assault and a federal firearms charge in the Dec. 4 incident that drew national headlines to the Connecticut Avenue retail block where the restaurant is located.

Welch said court to U.S. District Judge Ketanji Brown Jackson, “I wish there were a way that I could offer something other than an apology... I realize mere words can’t undo what happened...but I am sorry,” said Welch, wearing an orange prison suit and standing with his hands clasped behind his back.

“I am sorry for anything I have caused,” Welch said.

In imposing the sentence, the judge said she was handing down a penalty she said was needed to uphold the rule of law against vigilante justice.

“I hope you understand and see how much people have suffered because of what you did,” Jackson said going on to say “I am truly sorry you find yourself in the position you are in, because you do seem like a nice person who on your own mind was trying to do the right thing. But that does not excuse reckless conduct and the real damage that it caused.”

(Whitney Shefte/The Washington Post)

In a previous letter filed in court, Welch said he had not intended to “harm or frighten innocent lives, but I realize now just how foolish and reckless my decision was.”

His attorney, assistant federal defender Dani Jahn, had said in court records that Welch “does not seek to minimize the impact his reckless and frightening actions had on those who encountered him. . . . Rather, Mr. Welch is hopeful that those victimized by his actions can forgive him.”

Federal prosecutors countered in their memo to the judge that it was “entirely the product of good luck” that no one was shot. They urged Jackson to send a strong message to deter those who would commit violence based solely on “malicious and misguided” Internet rumors.

“Beyond Pizzagate, the Internet is full of wild conspiracy theories where people urge members of the public . . . to take action,” wrote the assistant U.S. attorneys Ahn and Sonali D. Patel.

Welch of Salisbury, N.C., traumatized employees, customers and many in the community, prosecutors wrote, adding that he “made clear he had no respect for the public institutions of the District of Columbia, telling detectives that everyone in D.C. is ‘crooked,’ ” including the FBI, whom he did not trust to investigate the supposed crimes.

“A significant sentence is required to deter other people from pursuing vigilante justice based only on their YouTube feed,” prosecutors wrote.

In plea papers, Welch, a father of two young girls, acknowledged that he had become agitated by reports and videos he read and saw online about the supposed sex ring before loading his Toyota Prius with arms and ammunition for the drive from his home to Washington.

“Raiding a pedo ring, possibly sacrificing [sic] the lives of a few for the lives of many,” Welch wrote in one of several text messages in an unsuccessful effort to recruit friends for what he said would be a violent confrontation, authorities said.

“Standing up against a corrupt system that kidnaps, tortures and rapes ­babies and children in our own back yard,” he wrote in another exchange.

Welch binge-watched YouTube videos about the alleged child-trafficking ring on Dec. 1, setting a plan, court files show. Still, Welch was warned by a friend and his girlfriend against doing “something stupid,” as she put it in a text that was included in court filings. Using a “camera” and conducting “recon” first would be better than going to the restaurant with “guns blazing,” the friend advised in other messages cited by authorities.

Finally, as he drove to Washington, Welch texted his girlfriend a Bible verse about being anointed by God and recorded a message to his family saying he loved them and hoped his daughters would understand someday that he was trying to protect the defenseless.

Shortly before 3 p.m. Dec. 4, Welch parked and left a loaded 12-gauge shotgun and box of shells in the car, then walked into the restaurant carrying a loaded, six-shot revolver on his hip and holding the 9mm long rifle with about 29 rounds of ammunition across his chest.

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 state. He also pointed the rifle toward an unwitting employee retrieving pizza dough who entered at the back of the restaurant and then immediately turned and ran for his life, according to the government’s evidence signed off on by Welch.

Welch ultimately did not shoot anyone and surrendered after he found no evidence of hidden rooms or sex trafficking.

Welch has agreed to forfeit the rifle, the 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.

In March, 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 saying that neither the restaurant owner, Alefantis, had anything to do with human trafficking. The statement came after Alefantis’s attorneys had requested a retraction.

Separately, a Shreveport, La., man, Yusif Jones, pleaded guilty last winter to telephoning a copycat threat to a nearby pizza shop on Dec. 7, saying: “I’m coming to finish what the other guy didn’t. I’m coming there to save the kids, and then I’m going to shoot you and everyone in the place,” according to court charging documents.