Up to this age, a preschooler is used to communicating non-verbally by crying, throwing tantrums, laughing etc. So far he has also been cocooned within the confines of a sheltered home where he receives attention. So suddenly, when he has peers and most likely in a new surrounding, he will probably use his fists to communicate his wants.
Now is the time to encourage him to use words to communicate. It may be difficult for him in the beginning, and might not seem interesting enough, but with constant encouragement he will soon be able to ask for things rather than to grab or hit. It is important to teach him the negative result of hitting and the consequences he will bear because of it.
Explain to him that he will have to face the ill will of his peers as well as punishment from his parents.
Be consistent with your punishment. If you are not, your child will soon try to manipulate you and get away with his actions. This will bear negative results in the long run, even as the child grows up to be an adult.
If a child has developed the habit of hitting or resorting to other forms of violence with his peers, you might want to monitor his behavior around friends, and identify the incidents that make him angry. You will be able to identify if whether it is a person that irritates him or an action such as grabbing his toy. If you notice that a certain set of friends or a certain friend is triggering this behavior consistently, you may want to find him a new friend.
Remember that two is company and three is a crowd. A child usually plays better when he has one person to play with rather than a group.
While correcting a child, do it immediately, so that he is not confused about why you are correcting him. Also do this in private. Gently pull him away from the group and then talk to him. Try leaving him alone for a while, like time out while he cools off. A time out is generally given according to age - one minute for every year.
Try playing games that are not very competitive at this stage. Role plays and games where everyone gets a turn to be recognized are better options. Play games that encourage communication.
After a good play session, praise his good behavior and reward him accordingly with something he likes or something that has been agreed on beforehand.