It sounds like your son is trying to comfort his Dad by pushing you away. In his mind he might think that his Dad is more ‘deserving’ of his love and attention because you are being seen by him as rejecting your ex so he might feel a need to offer comfort. By rejecting you he’s making his Dad happy (from his view).
Obviously your son is too young to really remember you as a couple and hopefully isn’t fully clued up on why you and your ex split up so it’s easy for him to put the blame on you. From his perspective Dad wants to reconcile and reunite the family and it’s Mummy’s fault that that can’t happen.
It is entirely unfair of your Ex to make these types of comments to your son and for him to encourage him to pick favourites. Your ex is probably really insecure and feels he can’t be entirely bad/in the wrong for the way he treated you if your son thinks he’s the better parent. I would hazard a guess that Dad is also the ‘fun’ parent which also helps skew your child’s view of things.
If you are able to speak to your ex I would ask him to consider the impact his words have on your son. It is unfair to use your son in this way and could be seen as an attempt at starting parental alienation. Make it clear that you don’t want your child to be responsible for his Dad’s emotional wellbeing, he is the grown up and needs to stop projecting on to and leaning on a child. If he’s sad and lonely he needs to talk to another adult, not complain to a 9 year old. He may well want to get back with you but that is not his call to make and is confusing for your son to hear.
He might be sad he can’t do things with you as a family unit but his actions caused that and saying it out loud to a child is manipulative, even if he doesn’t mean for it to be. Instead of saying ‘Daddy wishes he could come’ he should be phrasing it as ‘you’re going to have so much fun, I can’t wait to hear all about it’.
His words and actions are negatively impacting your child and will ultimately affect his emotional development. I doubt either of you want your son to grow up to feel he has to fawn over someone at the expense of his own happiness, this type of learnt behaviour can be really detrimental to how people behave in adult relationships. It may be your ex is not doing this intentionally (I really hope he’s not) but he needs to realise that kids are extremely impressionable and learn how to navigate relationships based on what they are exposed to in early life.
Try talking to your son and explaining that although you and his dad aren’t together (and won’t be getting back together) you both love him equally. That you love him and his sibling the same and that no one has to pick favourites because love isn’t limited. That grown ups get sad too sometimes but it’s not his responsibility to make his Dad feel better.
Is there anyone at school who you could ask to speak to your son about this? Might help him understand/express his feelings/thoughts if he can speak to a non involved adult.