BANGOR, Maine — Robert Berg repeatedly refused to get involved in his old friend Malcolm French’s marijuana operation in Township 37, a federal judge said Friday.

Berg, 52, of Corinna, told the man he’d met playing basketball when both were in the fifth grade that it was just too risky, U.S. District Judge John Woodcock said in sentencing Berg to six months behind bars.

But when French called his childhood buddy on Sept. 23, 2009 — the day after the pot farm was raided by state and federal drug agents — and begged for his help, Berg acted out of loyalty, the judge said.

The Corinna businessman picked up seven or eight undocumented workers who had worked the farm and were hiding in the woods of Washington County. He hid them in his barn and gave them food, shelter and clothing for at least 24 hours before they were whisked out of state by others.

“Unfortunately, when put to the test between personal loyalty and adherence to the law, the defendant faltered,” Woodcock said Friday.

Berg pleaded guilty Jan. 7, 2014, to being an accessory after the fact to manufacturing 1,000 or more marijuana plants at a large marijuana farm in Township 37.

In addition to prison time, Berg was ordered to pay a $10,000 fine and to serve one year of supervised release after he completes his prison term.

An emotional Berg told Woodcock before he was sentenced: “I’m guilty. I did it. I apologize to everybody. I’ll repay society and get back on track.”

Assistant U.S. Attorney Joel Casey recommended Berg serve a year and a day behind bars and the fine the judge imposed. He said that Berg’s actions delayed the prosecution of his co-defendants and the investigation cost taxpayers thousands of dollars that would not have been spent if the workers had been caught within a few days of the raid.

“It took three years for the government to find three of the workers,” Casey told Woodcock. “Four or five of them just disappeared and were never heard from again.”

Using DNA found in shacks at the grow site allowed technicians at the Maine State Police Crime Lab to create profiles for seven men, Casey said. None of them matched known profiles. It was not until one man was convicted of a sex crime in Indiana that investigators were able to begin unlocking the case.

Casey said that because “Berg gave into a misguided sense of loyalty to Mr. French rather than do the right thing,” he should be incarcerated for no less than a year.

Berg’s attorney, Richard Berne of Portland, urged Woodcock to impose a sentence of home confinement and community service.

“In a moment of weakness, he made a bad decision that has had enormous consequences,” Berne said.

The attorney said that after Berg pleaded guilty to the federal felony 18 months ago, his screenprint business has suffered.

“Mr. Berg has lost customers and he lost his line of credit with the bank,” Berne said. “The business will be in serious jeopardy if he is not able to travel and meet with customers for the next year.”

The attorney also said that 75 people had submitted letters in support of Berg and his charitable works in the community.

Berg remains free on bail. He was ordered to begin serving his sentence on Oct. 16.

He faced up to 15 years in prison and a $5 million fine on the drug charge.

His co-defendants, French, 53, of Enfield, Rodney Russell, 51, of South Thomaston and Kendall Chase, 58, of Bradford, were found guilty on a variety of charges in connection with the pot farm on Jan. 24, 2014, following a 10-day jury trial.

They are scheduled to be sentenced along with Haynes Timberland Inc., the firm that owns the land where the farm was located, by Woodcock on Sept. 30.

In a separate case, Berg admitted on June 23, 2014, that his custom screen printing and embroidery company created fake logos for sports teams, a distillery, a tractor company and a motorcycle manufacturer.

On Friday, Woodcock ordered the company to pay a $10,000 fine and to pay $11,855 in restitution.

Robert Berg Enterprises Inc., doing business as Berg Sportswear Inc., owned by Robert and Heather Berg, both of Corinna, had been under investigation for trafficking in counterfeit goods, money laundering and tax evasion for more than three years, according to court documents.

In sentencing the firm, Woodcock said that it illegally used the logos for five years because Berg believed he would not be able to sell the items to his customers at small businesses and convenience stores if he had to pay the licensing fees.

The business, which continues to operate, produced more than 18,000 items using the logos without permission and had sold 9,800 of those when it was raided in 2011.

The maximum fine for the charge of trafficking in counterfeit goods was $5 million. The law requires judges to impose fines that will deter similar behavior but allow a business to continue operating.