L.R.
Please get to the library or bookstore and get the book "Queen Bees and Wannabes." It will shed a lot of light both on your daughter and on M, and the whole dynamic they're developing. M is a queen bee. And she has a sting that will get worse.
M. is not "harmless" as you put it. Though I'm also not saying she's going to grow up to be dreadful -- she could be a great kid overall and turn into a wonderful adult, as you'll see when you read the book -- I am saying that right now, right here, it's time for your daughter to move on and do some activities that will get her closer to other friends, old or new. The summer break can be a big help here: Unless you already shelled out unrefundable big bucks for the camp, you could consider finding something else for your child to do that week (if your girl has her heart set on it, I would still let her go; but if she is ambivalent, give her the "out" of saying, "It's your choice and it really truly IS all right if you choose to do something else.").
Have plenty of play dates this summer with other friends, and maybe a very few with M. if the girls get along OK one on one (no group play dates with M or she will work to be the center of attention). Have activities for the kids to do, whoever is over - specific things like crafts your daughter has chosen and organized, events to attend, etc. rather than a ton of hang-out time that ends up in words exchanged and tears flowing.
I'm sorry there's no option for another class to separate these girls. So there is only one GT class in the school for this grade? That is tough. I would just ensure that your daughter has lots of activities that do not involve M (if they're in the same GS troop, have you talked privately to the leader about M's behaviors and asked for her help ensuring that M does not dominate everyone? A good leader should already be aware of that tendency and should already be curbing M if she runs over other kids' feelings or hogs the limelight!).
The party sounds like it's wounding you as much as, maybe more than, it would wound your daughter. Do not resent your friend whose daughter is going -- there are parties all the time and you know there's no reason to resent a parent who lets an invited child attend; just because your friend also sees M is a queen bee does not mean your friend's daughter must be made to stay home in solidarity with your own daughter. Let the whole party thing go or it will be your daughter who catches flak if other kids find out her mom said something to M.'s mom. M's mom sounds like a piece of work herself, and if you confront her about your child not being invited, she likely will tell her daughter and that will ramp up the drama among the girls. Silence is the best option here for you.
Do look at the book and see where your daughter is on the spectrum of friendships and not-so-friendly relationships. There will always be girls like M. so teach your daughter how to handle these kids for herself, because you can't always be there to defend her -- nor should you.