1) Communicate, communicate, communicate. You cannot over-communicate. Open the door, and make sure it stays open. Be a constant positive force in your child's life
2) Positive reinforcement. Most kids are good kids, they just get troubled and lose their way. Leave him with tape-recorder running inside his head, that he can't turn off. Tell him that he's a good kid; to hang on in there. that you love him and believe in him, over and over and over. Give him the "tools" he needs to find his own way home. You will need to discipline him, but always stress the positive.
3) Find a mentor. If your child's father can't be that mentor,then look for a strong male friend, or relative or even a volunteer from a mentoring organization. Get him involved in organizations, sports clubs, social clubs or church groups, places he can find support and strong peer support, as well as a 'coach' or male role model.
Kids join gangs for any number of complex reasons. Before you condemn him, try to better understand what's driving your child down this path.