Relax - this is perfectly normal behaviour!
Your daughter is finding her sense of self, and she learns this behaviour at school, and is trying it out to see what happens. It's pushing boundaries, and children do it up to, and increasing - adolescence, but don;t panic - you can get past this.
OK, first of all you need to set some boundaries. This is what your daughter is seeking, although she is unaware of it, so don't bother trying to explain it to her. What she wants is to find out where the lines are, so that she will feel secure. Failure to put them in will make her behaviour steadily worse.
So - when she is good make a real fuss of her, so that she knows that good behaviour pleases you. All children love approval, so encourage her with lots of praise and affection.
When she is naughty, be cold to her. Look her straight in the eye, with a stern face, and say "What you are doing is making mummy sad, I don'pt want to be with you when you are like this." and blank her. When she throws a wobbly, and she will, tel her that you will be nice again when she says sorry. Stick it out until she does, and then give her a cuddle and say that you don;t like her to be unkind, and you love her when she is good, and you can be happy together.
Stick rigidly to this formula - if you deviate you will loose - she needs to know what a nice reaction she gets to good behaviour, and that bad behaviour will not be tolerated.
Steel yourself when she cries, it will hurt you, but she will forget it in five minutes. Don;'t panic about 'damaging her - children think totally differntly from adults - you are training her to live in a family group, and she will respond if you are consistant.
Eventually, as she realises that her bad behaviour doesn;t get a reaction from you, except withdrawal, she will stop it.
ctd.