My son's preschool taught him to respond to unpleasant treatment from a classmate in a format that seems to be still working well for him in 3rd grade:
In a firm voice, say, "[Name], no thank you! Don't [do that]. I don't like it." Then move away, if feasible.
I wish someone had taught me that when I was little. Often I was so shocked that someone would be not-nice to me that I didn't know what to say or do, so just stood there shrivelingly wondering if I deserved it.
He has had just a few incidents where the bothersome kid was very persistent. One of these was a new student who didn't speak English and apparently didn't understand what my son meant from his tone and body language. At that point he told the teacher (kindergarten) who appallingly responded, "Nobody likes a tattletale." We made several attempts to discuss this with her, during which she claimed that the other boy couldn't possibly be expected to learn appropriate behavior "because of his culture" and that he "wasn't really bothering" my son who was "just looking for an excuse to disrupt circle time." Meanwhile we were hearing from our son that "Nobody likes a tattletale." was the teacher's standard response on a daily basis every time any child complained about another and that some kids were being picked on to the point of tears and getting no help. We finally had a meeting with her and the assistant principal, who told the teacher this was not an appropriate response and she needed to do something to distract or separate students who were having a problem, especially if it was ongoing. While that classroom always was a little uncomfortable (and the teacher clearly resented us for "telling on" her), it did get better after that, and my son was no longer required to sit next to this boy who had been poking and jabbing him.
He also had, just recently, an incident where he was telling a classmate to stop whispering at him because he was trying to listen to the teacher, but because his firm voice was louder than her whisper, the teacher noticed HE was talking, reprimanded HIM for it, and even put a comment about it on his report card. No fair! I told him most of us have this kind of experience at some point in our school years; try to forget it and move on; if she's whispering at you again, write a note that says, "Please be quiet! I'm trying to listen!" so that if you then get in trouble for writing a note, you can show the teacher what it says!