Don't panic, this is perfectly normal for a child to go through a period of adjustment when they start school.
For the first time ever, he is experiencing discimpline in a group environment, and he will observe the behaviour of others, and imitate it, simply to see what the reaction is.
Have a word with his teacher and explain the issues, and ask advice.
The best way forward to is to ensure a continuity of discipline at home and at school. If he is made to behave at school, he will be ready to run amok at home. What ytou have to do is instill the same rules of behaviour with similar sanctions, so there is a thread of action and reaction, and he begins to understand that he must do as he is told by the adults in his life.
Be firm, do not deviate, even if he cries and wants a hug, you must make sure that the rules are obeyed. Being cross and then loving sends out confusing messages, and his insecurity will increase.
He will learn - being nice gets nice reactions, being nasty gets punishment, so reward his good behaviour but always always punish the bad behaviour.
FFor the record, this will be harder for you than for him. he will have forgotten the incident way before you stop beating yourself up over being angry with him.
Be firm, be strong, he will respond to the security of a disciplined environment.
Good luck!