A sheriff's deputy working security at the Berkeley County courthouse in December sold a shotgun and a revolver to defendants facing felony charges, according to a federal indictment.

The allegations against Tony Allen Riley, 60, were detailed in the court document that was made public Wednesday.

Riley was fired from his law enforcement post at the Berkeley County Sheriff's Office after agency officials learned of his arrest Monday, Maj. Rick Ollic said.

He had served with the agency for more than 18 years.

An attempt Wednesday to contact his attorney, Grover Beau Seaton of Moncks Corner, was not successful.

The indictment from a federal grand jury charges Riley with two counts of knowingly selling a firearm to a person prohibited from owning one. Each charge is punishable by up to 10 years in prison.

Agents from the Federal Bureau of Investigation led the investigation into the case. How they learned about it wasn't immediately known.

Sheriff's officials said they found out about the accusations only after Riley's arrest. They said his alleged conduct was an aberration among their deputies.

In each instance, the federal paperwork stated, Riley sold a gun to someone who was under an indictment for a crime punishable by more than a year in prison. Under federal guidelines, such a charge is considered a felony.

Those criminal defendants are prohibited from having firearms.

A jailhouse correctional deputy for most of his career, Riley transferred to the courthouse in Moncks Corner after he was demoted in early 2012 for mistakes he made in an inmate's escape.

His indictment does not identify the gun buyers, though, and does not specify how Riley met them.

Riley knew that they were accused of felonies, the indictment alleged.

The first instance came Dec. 17, according to the document, when Riley sold someone a Mossberg Maverick 88, a pump-action 12-gauge shotgun.

On Dec. 19, another person purchased a .38-caliber Smith & Wesson CTG revolver from the deputy, according to the charge.

Whether Riley was booked into a jail after his arrest Monday wasn't immediately clear. He was freed on $25,000 bail the next day.

The Sheriff's Office first hired him as a correctional deputy in April 1995, according to records from the S.C. Criminal Justice Academy.

Riley was certified as a law enforcement officer outside jailhouse walls for the first time in early 2006, but he retired as a lieutenant from that position in October 2008, Ollic said.

He returned to the Sheriff's Office in March 2009.

He was serving as a lieutenant in January 2012, when the Sheriff's Office faulted him for some of the mistakes that led to an inmate's escape. Officials said he didn't fully read the inmate's file before approving his release.

He was demoted to sergeant that February. Later in the month, he took an opening at the courthouse as a private first class, Ollic said.

"He filed his grievance, but the demotion stood," Ollic said.

"There was an opening (in courthouse security), and he transferred. That was his decision."

Reach Andrew Knapp at 937-5414 or twitter.com/offlede.