The North Carolina man who fired a rifle inside a Washington, D.C., pizzeria as he chased down an internet rumor related to Hillary Clinton was sentenced Thursday to four years behind bars.

Edgar Maddison Welch, 28, had pleaded guilty in March to two charges stemming from the Dec. 4 incident at the Comet Ping Pong restaurant. Prosecutors say he was self-investigating an online conspiracy theory — dubbed "Pizzagate" — that claimed the pizzeria was harboring a child sex-trafficking ring with connections to influential Democrats. Washington police and the FBI denied the theories had any substance.

Federal Judge Ketanji Brown Jackson said Thursday that even though Welch didn't harm anyone, his unsound actions "literally left psychological wreckage," according to The Associated Press.

Jackson added that Welch still went ahead with his "ill-conceived plot" when others warned him not to, and that he should have simply contacted law enforcement if he believed the restaurant was engaged in something illicit — instead of driving the more than 4-1/2 hours from his home to the nation's capital to "rescue" the nonexistent children.

Edgar Maddison Welch appears in federal court in December 2016. Art Lien / NBC News

Welch apologized for his actions and told the judge that he "cannot undo or change what already happened," the AP added.

Welch's attorney sought a sentence of 1-1/2 years, while prosecutors asked the judge for as much as 4-1/2 years.

Related: Five Tips on How to Spot Fake News Online

He had initially been arraigned on charges of assault with a dangerous weapon, carrying a pistol without a license and other crimes. Prosecutors say he was armed with an AR-15 rifle and a .38 caliber handgun during the bizarre episode.

An evidence photo showing the AR-15 assault weapon Edgar Maddison Welch of North Carolina brought in to a District of Columbia pizza restaurant on Dec. 4, 2016. Metropolitan Police Department / via AP

Witnesses told police that they heard Welch fire three times inside the restaurant. He surrendered peacefully after finding no evidence of sex trafficking.

The New York Times reported in November that Pizzagate appeared to have come from the email hacking of Hillary Clinton's former presidential campaign chair, John Podesta, who casually knows the owner.

Podesta and he previously shared emails about a fundraiser, which in turn ramped up speculation about a child-abuse ring that gained momentum on internet message boards despite there being no validity to it.