Margera pleaded guilty to two counts of disorderly conduct on Wednesday.
He will spend six months on probation and will be subject to random drug testing.
In court, Margera said he is thankful for this situation, saying it helped him clean up his act.
After court, Margera told Action News he looks forward to continuing sobriety journey, and getting back to skateboarding.
"I needed that to realize I would go on drinking benders and I would end up in situations that were really not good," Margera said after court.
He says August 1 will mark his one year anniversary of sobriety.
"Now that I've done this amount of time, I don't want to go back to that lifestyle," he said.
Judge Patrick Carmody said Margera's recent sobriety is what the entire family was after and that it must continue during the probation time period.
However, if he tests positive for drugs he could face jail time.
Margera had been charged with assaulting his brother and making threats to other family members during what the brother called a "frightening and unpredictable" two-week visit home last year.
The plea ends a long legal case that spun out of his stay at the Chester County home known as Castle Bam. At a hearing last year, Margera told the judge he was getting drug and alcohol treatment.
Jess Margera, at the same court hearing, called his brother "a good dude when he's not messed up" but said he had exhibited troubling behavior for two decades and, while home, had been awake for days. Jess Margera suffered a ruptured eardrum in the altercation, while Margera's girlfriend called police when he kicked in her bedroom door, the brother testified.
Margera was on the run from police for a few days before turning himself in.
Bam Margera speaks exclusively with Action News ahead of assault trial
Bam has struggled with mental health and substance abuse in the past.
His mother April was at Wednesday's hearing. Though their relationship is strained, she was there to show support.
"He's doing really well and we want him to keep going and get this behind him, really. But we all love him and we just want him to do great," she said.
"He's been through a lot in his life, he's had a lot of access and he's had a lot of power and it's hard to come down from that," she continued.
Chester County District Attorney Christoper de Barrena-Sarobe says this type of plea deal isn't uncommon.
"We want to make sure Bam can get the help that he needs. We want to see Mr. Margera have accountability on the back end so that he can achieve the sobriety and that he can really be accountable to his family and his community," de Barrena-Sarobe said.
The Associated Press contributed to this report.