A federal judge who was shot in the leg and wounded acted heroically by trying to keep the assailants out of his Detroit home and away from his family, a prosecutor said Friday.

Terrence Berg, a judge on the U.S. District Court in Flint, was shot Thursday night outside his home while taking out the trash.

"Two robbers demanded access to his home and he refused. That's when he was shot," U.S. Attorney Barbara McQuade said. "He was very heroic. He's paid a price for it, but fortunately it's a wound to the leg. He's going to recover."

She said the attack doesn't appear to have been motivated by Berg's work as a judge. He was scheduled to have surgery on Friday.

His wife, Anita Sevier, said she heard a gunshot and her husband yelling for help.

"It was a big ordeal, but he's going to be OK," Sevier told Detroit-area radio station WWJ.

Authorities haven't identified the two suspects.

Berg, 55, has been a judge for two years. He served as a federal prosecutor for two decades and was briefly head of the U.S. Attorney's Office in Detroit.

"He's very active in his community," McQuade said. "I doubt it will dampen his enthusiasm for the city of Detroit."