A U.S. Capitol police officer who tried to help a Virginia fisherman avoid criminal charges for storming the building his law enforcement colleagues defended was sentenced on Thursday to two years of probation and four months of home detention.

Michael Angelo Riley, a 25-year police veteran, was on duty when a mob attacked the Capitol on Jan. 6, 2021, injuring more than 100 officers. Riley's voice cracked as he lamented how his "awful judgment" cost him his career, tarnished his reputation, ended friendships in the department and traumatized his family.

"The amount of regret and remorse I have over this situation in unimaginable," Riley told U.S. District Judge Amy Berman Jackson before she sentenced him.

EX-FIREFIGHTER GETS 52 MONTHS FOR THROWING FIRE EXTINGUISHER AT CAPITOL POLICE

Before the hearing, prosecutors recommended a prison sentence of two years and three months for Riley. Jackson agreed to spare him a term of imprisonment.

The judge said Riley's actions were "shocking conduct for any member of law enforcement."

"You knew exactly how bad January 6th was," she added. Jackson also ordered him to pay a $10,000 fine and perform 150 hours of community service.

On Jan. 6, 2021, Riley investigated a report of an explosive device at Republican National Committee headquarters and helped an injured officer. The following day, he posted a Facebook message calling for federal charges against anybody who assaulted police, damaged property or breached the Capitol.

"If we don't send a message it will surely happen again," he wrote.

Less than two hours later, Riley read a Facebook post by Jacob Hiles, a fisherman he knew from YouTube videos. Hiles wrote about his own participation in the riot and posted a video of rioters clashing with police.

Capitol riot protesters in Washington, D.C.

A former Capitol police officer has been spared a prison sentence after he was caught tipping off a Jan. 6 rioter about the investigation into the incident and urging him to delete evidence of his participation. ((AP Photo/Jose Luis Magana, File))

Riley, 51, of Maryland, privately messaged Hiles and identified himself as a Capitol police officer who agreed with his "political stance."

"Take down the part about being in the building they are currently investigating and everyone who was in the building is going to be charged. Just looking out!" Riley wrote.

They continued to exchange friendly messages until Hiles told Riley that the FBI was "very curious" that they had been communicating.

"They took my phone and downloaded everything," Hiles wrote.

Riley immediately deleted all of their private messages, according to prosecutors.

Riley was charged with two counts of obstruction of justice. In October 2022, a jury convicted him of one count but deadlocked on the second.

Riley described his actions as "stupid and reckless" but said he didn’t think he was breaking the law.

"It certainly doesn’t excuse my lapse in judgment," he said.

Riley "fully understood the horrors of" the Jan. 6 attack, Assistant U.S. Attorney Christopher Howland said in a court filing.

"And yet, when the time came for (Riley) to hold the line, he sided with a known rioter, a person he had never met or spoken to, because of the rioter’s political views and because he happened to be a good fisherman," Howland wrote.

Riley's lawyers said he already has paid a steep price for contacting Hiles: He has lost his job and his K-9 partner, a dog named Toby.

"If he could do it all over again, he never would have contacted him," they wrote.

KANSAS CITY MAN INVOLVED IN CAPITOL PROTESTS CLAIMS TO BE 'RIDICULOUSLY ASHAMED' BEFORE SENTENCING

Hiles pleaded guilty in September 2021 to a misdemeanor count of parading, demonstrating or picketing in a Capitol building. Jackson sentenced him in December 2021 to two years of probation and ordered him to complete 60 hours of community service.

More than 1,000 people have been charged with federal crimes related to the Jan. 6 riot. Over 600 of them have pleaded guilty or been convicted after trials decided by a jury or judge. Over 450 of them have been sentenced, with over half getting terms of imprisonment ranging from seven days to 10 years.

More than 100 police officers were injured at the Capitol on Jan. 6.

Also on Thursday, a different judge is scheduled to sentence a Michigan man who pleaded guilty to assaulting a police officer at the Capitol during one of the most brutal clashes between rioters and law enforcement.

CLICK HERE TO GET THE FOX NEWS APP

Logan Barnhart, a pipelayer who modeled for covers of romance novels, grabbed an officer by his neck and torso and dragged him into the crowd of rioters on the Capitol’s Lower West Terrace. Minutes later, Barnhart returned to a police line and struck other officers with a flagpole.