A Pennsylvania judge ruled Thursday that "Jackass" star Bam Margera will have to stand trial after an altercation with his brother in May.

The judge also ruled that Margera must get a drug and alcohol screening test to continue to be free on bail.

The actor pleaded not guilty to one count of simple assault, harassment and four counts of terroristic threats. He has been free on $50,000 bail and said Thursday that he has been in drug and alcohol treatment this year and living with former Los Angeles Lakers star Lamar Odom.

Bam Margera in a black hoody looks off in distance

A Pennsylvania judge has ruled that "Jackass" star Bam Margera will have to stand trial after an altercation with his brother in May. (Paul Archuleta / FilmMagic / File)

"I’m not trying to get him in trouble here. I just want him to get the help because I feel like this is our last chance," Margera's brother, Jess Margera, said while testifying about what he called two decades of troubling behavior by his brother. 

BAM MARGERA'S MOM OPENS UP AS PENNSYLVANIA POLICE SEARCH FOR TROUBLED REALITY STAR: 'WE ALL LOVE HIM SO MUCH'

According to Jess, the situation with Bam escalated to a "frightening and unpredictable" two-week visit home in April.

Jess said the alleged incident occurred after Bam saw a text message that suggested he needed to seek mental health treatment. The 43-year-old actor then allegedly struck Jess in the nose and ear and ruptured his eardrum.

Bam Margera flashes his hands on the red carpet with sunglasses on his head and a scarf covering his head in a purple shirt

Bam Margera pleaded not guilty to the assault and harassment charges. (Frazer Harrison / File)

Jess' girlfriend called the police after Bam kicked down her door, according to Jess.

Margera allegedly "fled the residence on foot to the rear of the property through a dense wooded area" when law enforcement arrived on the scene. Authorities were dispatched to Margera's home in Pocopson Township in Chester County for a reported "domestic-in progress" call at the time. Margera later surrendered to authorities.

"I don't know what we’re doing here," lawyer Michael van der Veen said. "This is a disagreement between two brothers on a Sunday morning over coffee."

CLICK HERE TO SIGN UP FOR THE ENTERTAINMENT NEWSLETTER

Prosecutors agreed to drop two of four counts of terroristic threats, which stemmed from allegations that Bam Margera threatened to shoot various family members and left his brother a threatening note. Neither the brother nor prosecutors suggested that he had access to a gun.

By the end of the hearing on Thursday, which was delayed for several hours by Bam Margera's late flight from California, both sides seemed most interested in ensuring that he remains in treatment.

Bam Margera poses with Johnny Knoxville and Steve-O at MTV Video Awards

Bam Margera found fame with the "Jackass" crew. (Frank Micelotta Archive / File)

"We want to make sure you're safe, secure and alive," said Judge Albert Iacocca, who asked what had motivated him to go to treatment this year.

CLICK HERE TO GET THE FOX NEWS APP

"To see my son, Phoenix, who's 5," Bam Margera said.

Bam found fame with the rest of the "Jackass" crew, a group of amateur stuntmen who were known for filming their wild antics. It aired on MTV from 2000 to 2001.

The Associated Press contributed to this report.