S.S.
One of my sons did this when he was about that age. The most important thing was to not let it get to me. You need to be sure that you don't take it personally. Try not to react, just respond. I would just calmly tell him that he seemed to feel really angry with me, but that, although I was disappointed, I still loved him anyway, and that when he was ready, I would love a nice hug from him. Nine times out of ten, I didn't even get out of the room before he would start to cry and say, "no, Mommy, I really do love you! Don't leave!" If you can continue to stay calm, and simply love him, even when he least appears to deserve it, it will end - not right away, but it will end. Getting angry or confrontational with him will only cause him further upset and confusion.
I can't really comment on why he's doing it - my son was likely responding to the difficulty my husband and I were having in our marriage (we ended up divorcing eventually). But, frankly, it could just be an 'age' thing. As a foster parent for many years, I generally preferred not to have 4yr olds - they're definitely difficult! My son is now 29 yrs old, and is such a sweet, sensitive, loving man - he is a true light in my life!! Best of luck with your little man......