We've gone through many friend issues over the years and it's so hard because you want to see your child happy but you can't go there yourself and fix it!
We help by "playacting" the different situations and we try to let her come up with solutions. We guide her to the right solutions, but we don't tell her what to do.
First you have to find out what's going on. Sometimes you have to drag it out of them, but you'll know when you have it all. Sometimes at first you'll get the "they're doing everything to me and I'm just a victim" version but keep gently asking and eventually you'll get the truth. Rarely is you child a complete victim, although girls can be very mean.
Then we playact the situation with different solutions. Usually we start with dolls like Barbie dolls and we often give the Barbie dolls different names than the names of the girls and my daughter. I think this helps the child to separate themselves from the issue. We playact the situation and come up with solutions and act them out until we come up with something that works and that is comfortable for our daughter. Then we switch it up and the Barbie dolls are the actual girls, and my daughter is the Barbie doll that is her. We play the other girls and she handles the situation with the new solution. Sometimes we have to let her be the mean girls first and we are the doll that is her so she can see how it works.
Once she has that down then we playact without the dolls. She is herself and we are the mean girls. We'll start easy, but we gradually get tougher and tougher. It's her job to do the solution we came up with. In the case of a bully at school, we had her practice ignoring the bully, and then if the bully got physical she was to stand up, say "NO!" really loud and then go get the teacher.
It quickly turns into a game, which is fine. It always ends in laughter. You know you're done when your daughter seems relaxed about it.
The funny thing is, we've had to do many scenerios over the years for different situations and after we did the playacting the situation has never come up again where she even had to use what we practiced! Even things that were going on for weeks! It's like it gave her confidence that the bullies or mean girls could see and they just didn't try it. I think it's kind of like learning martial arts, sometimes after you learn it you never have to use it!
This has always worked for us. Even for situations where girls are fighting because they just want to do their own thing.
Good luck!