A northern Alabama sheriff was in federal custody Thursday after a judge ruled he purposely fed inmates skimpy meals so he could make money from an unusual system that lets sheriffs turn a profit on their jail kitchens.

Morgan County Sheriff Greg Bartlett testified at a Wednesday court hearing that he made $212,000 over three years by cheaply feeding prisoners — every cent of it legal under a Depression-era state law and reported on his tax forms as income.

But U.S. District Judge U.W. Clemon ordered federal marshals to arrest Bartlett after hearing a string of skinny prisoners testify they were served paper-thin bologna, bloody chicken and cold grits in the north Alabama county's jail.

"He makes money by failing to spend the allocated funds for food for the inmates," Clemon ruled after a daylong hearing in a lawsuit filed by prisoners over jail conditions.

Clemon said Bartlett, who has been sheriff for six years, would remain in custody until he submitted a plan to feed prisoners meals that are "nutritionally adequate," as required by a previous agreement in the lawsuit.

Ten prisoners testified that they were so hungry after meals they are forced to spend hundreds of dollars at a for-profit store inside the jail for junk food like oatmeal pies and chips.

"We had an apple on Christmas, and I think we've had them one other time," said Clifton Goodwin, who's been in Bartlett's jail for 15 months.

Alice Hines, who has two sons in the jail on drug charges, said she gives them all the money she can — $50 sometimes, $100 others — to buy food from the jail store so they won't go hungry. Prisoners are even forced to buy basics like salt, pepper and ketchup to spice up bland meals.

"You're supposed to pay for your crime, but good God, feed them," said Hines.

Bartlett's lawyer, Donald Rhea, said the sheriff would be incarcerated in his own jail, but the department declined comment on Bartlett's whereabouts. The U.S. marshal's service did not immediately return a message seeking comment.

Bartlett looked stunned as Clemon ordered him into custody. A lawyer for prisoners called his arrest "extraordinary."

"I was shocked by the amount of money he pocketed ... all while men and women in the jail go hungry," said Melanie Velez of the Atlanta-based Southern Center for Human Rights.

Sheriffs in 55 of Alabama's 67 counties operate under a Depression-era system allowing them to make money operating their jail kitchens. The state pays sheriffs $1.75 a day for each prisoner they house and lets the elected officers keep any profits they can generate. Bartlett said he also received money from the county and the U.S. government for housing federal prisoners.

According to testimony, Alabama's ethics commission cleared Bartlett of a complaint in December, turning aside allegations that he improperly used his office for personal gain by profiting from inmate meals. The ethics commission cited the state law allowing the practice and a previous legal opinion from Alabama's attorney general.

Clemon's order dealt only with Morgan County, but the longtime head of the Alabama Sheriff's Association said its impact will be felt around the state since counties lack money to feed prisoners and state budgets are stretched thin.

"It's going to be real far-reaching. It's going to affect a lot of counties other than this one," said association executive director Bobby Timmons.

Bartlett testified he made a $212,000 profit over the last three years to supplement his annual salary of about $64,000. Bartlett said last year's profit was $95,000 — almost half of the total jail feeding budget of about $203,000 for about 300 prisoners. Bartlett said profits from the jail store are used to pay for equipment and training and don't go into his pocket.