Good news? This is a stage and it will pass. Bad news? It will keep happening throughout childhood. What's more, as I've written in the past, none of this makes it easy for any parent to live through, even when you are the one in demand.
Ah, but there's more good news. This is not about favoritism. It's not that your child literally loves one parent more than the other at any given time and it's rarely an intentional withholding of affection. It happens because your son has reached a new level of cognition. He's more aware of "self" -- that is, that he is separate from you -- but he isn't totally clear that when someone leaves his vision they can return. When dad leaves, he's not yet able to reason, "Oh dad's not here, he must be at work, he'll be home later." Instead, when dad returns, it dawns on him: "Hey, you've been gone, haven't you? I'm unhappy you left me!" This is also a way a child to test out unconditional love. Think of it almost as if he's asking, "If I'm not nice to you, will you still love me? What about now? What about now?"
As hurt as the Out Parent may feel, the answer always needs to be yes. And keep in mind that who's In and who's Out can turn on a dime.
Here are some coping skills:
For the In Parent, don't rush in and "rescue" the situation when your son's rejecting dad. That translates to, "Oh, mom doesn't think dad can take care of me." Instead, before a transition, remind him of what's about to happen: "It's dad's night to give you your bath!" Remind your child, "Tonight is dad's turn. My turn will be tomorrow night." When you see an opening to sing your spouse's praises, grab it: "Did you know dad is a really good reader, too?" You can also grease the skids by encouraging the two of them to do some activity alone, without you.
For the Out Parent, develop tough enough skin so you can stand your ground matter-of-factly: "I know mom does this differently. That's OK. She has her way. I have my way. It's different, but it's OK." Be gentle but firm. Avoid reacting angrily ("If you don't want me to give you the bath, I won't! See if I care!") or ceding victory to your spouse ("See! He does love you more!")
There are two caveats to my suggestions:
1. The Out Parent should never force him/herself on a child. If your presence is heading for a knock-down battle, bow out gracefully before it comes to that "I hope it will be my turn next time."
2. If a child consistently truly can't tolerate one parent's presence, that may not be a preferential stage but it could be something as fixable as an intolerance for the scent of perfume or after-shave. On the other hand, if a child is openly hostile or negative, or can't bounce back when he is with you, seek professional advice.
3. It's OK to comment on a child's preference ("I can see you really enjoy spending time with Daddy these days."), but don't burden him with your hurt feelings or force him to choose between you ("You're making me feel really bad. Don't you love me as much as Dad"). If developing empathy is the goal, try the indirect approach from the In rather than the Out Parent: "I can see it hurts Daddy's feelings that you don't want to play with him. What would make it more fun for you?"