Anthony Anderson on what to expect as Chris Brown guest-stars on 'Black-ish'

The episode airs tonight.

"I've known Chris Brown personally since he was 14 years old and I had no idea that he was coming onto our show," Anderson told ABC News. He explained that it was an encounter between "Black-ish" co-creator Kenya Barris and Brown that led to the rapper's appearance on the show.

"Kenya was out one day having dinner and Chris was at the same restaurant and knew who Kenya was," said Anderson. "He walked over and said, 'Hey man, I love your show. I just wanted to let you know that I want to be on it. Can we make that happen?'"

"And the next thing I know, this episode was written and they were like, 'Yo man ... we got Chris Brown to do it!'" And I was like, 'That's great.'"

On tonight's episode, Brown plays Rich Youngsta, a popular rapper who collaborates with Anderson's character on an ad campaign that some find offensive in the episode. Anderson said Brown, despite his past run-ins with the law, got the role because he fits the part.

"Our show is written as it is and whoever we feel is best to come in and be best at this character," he explained. "Chris expressed an interest in it and it was like, 'I think ... we have that character for you."'

"I cannot wait till the truth comes to light about this incident and this situation," Brown said in an exclusive video sent to ABC News back in September 2016. "You know, because my character's been defaced and who I am as a person and my integrity."

For that incident, Brown was released on $250,000 bail. That case eventually stalled, with the Los Angeles District Attorney's Office not moving forward with charges, USA Today reported weeks after Brown's statement of innocence.

According to Anderson, "Black-ish" remains "unique" because it does "not shy away from" controversial topics, and tonight's episode is no different, given Brown's history and the character he is playing on the show.

"He did a masterful job at it," said the actor. "I think people are going to be pleasantly surprised by the work that he did," he added.

ABC's "Black-ish" airs at 9:30 p.m ET.