*Before Chris Brown’s alleged gun-pulling stunt earlier this week, the singer reportedly ran afoul of executives at Starz, causing the network to cancel his planned role on its most popular drama “Power.”

Page Six is reporting that executive producer and co-star 50 Cent promised the singer a major role as a drug dealer on the series, but the rapper never cleared it with his bosses at the cable channel.

“50 didn’t consult the network first, and execs were not happy when they found out about it,” said a source.

“The network insisted that Chris’ casting was not going to happen, because of fears about his anger issues. There was a big blowup, and they had to tell Chris he was not going to get the role. The news was delivered to him early Monday. He was livid,” the source continued.

Then, at 3 a.m. the following day, beauty pageant winner Baylee Curran called police claiming Brown pointed a gun at her after she was admiring a diamond necklace during a party at his home. When cops arrived, Brown wouldn’t let them in until they provided a search warrant. Waiting for it was an all day affair, covered live by TMZ and several networks.

Brown eventually emerged and was arrested on suspicion of assault with a deadly weapon and released on $250,000 bail. But Brown insists he was set up, and his lawyer, Mark Geragos, believes his accuser “fabricated” the gun threat.

50 Cent, who has worked with Chris on several tracks, defended the singer on Instagram after his arrest.

“That’s my boy. I watched him come up, a lot of the s - - t he go threw [sic] is crazy to me . . . If someone calls 911 and says you pulled a gun on them in your house, are the police coming to creat [sic] a bunker at the end of your drive way for 11 hours to wait for a search warrant? Then live stream it, This must be VIP Treatment. SMH.”

On Thursday, 50 Cent was still insisting Brown will be on the show, despite the network’s reservations. He told Page Six, “Tune into ‘Power’ next season, because you will see Chris Brown.”