Nothing too unusual in your son's behavior. At his age, he's excited about learning new skills and wants to have more self-control. Frustration is right at the heart of the "terrible" twos, threes, and fours. So much of what the child wants to do is thwarted by what the parents want or need him to do, and rules that make little sense to him.
There are a few tricks that will bring down his frustration level:
1. Give him advance notice when you'll want him to be doing anything differently, especially when he's grooving on his activity/play. With my 4yo grandboy, we let him know at least a couple of times that a change is coming ("Just a few more minutes." …"OK, one more minute and then X will happen.")
2. Whatever X is, make it sound as desirable as possible. In the case of toothbrushing, you might try an enthusiastic narrative like "Wow, you've been doing such a great job! Let's see if you missed any (puppies, fishies, dinosaurs…) in there. Here's a hand mirror so you can look with me! Oh, there's one right there; let me scrub it with this toothbrush …."
3. Talk up whatever is going to happen next, like story time, snuggling with mommy, etc. Again, be positive and enthusiastic. And be calm. Desperation will show, and even though your son is too young to deliberately engage in a planned power struggle, he will quite naturally sense any cracks in your resolve. And this is where future power struggles truly can begin.
4. Avoid bribes, but offer future rewards. Don't try to buy his cooperation with "If you'll do X, we'll let you have Y." Instead, phrase it as if he gets to assist in advancing something good for himself: "Hey, as soon as you help me get X done, then we get to do Y." It sounds like a small distinction, but it's important.
Little kids are just following their most natural inclinations, and experimenting with every automatic strategy possible to get their natural needs met. Your son tried several tonight:
He resisted letting you brush because he wanted to work at it independently for a longer time. This feels like quite a legitimate need from the child's point of view. Then he screamed to be listened to and taken seriously. Another legitimate need. He struck out for the same reason; he didn't believe you were hearing what he needed, and had no other resources left. Then he continued to scream, beg, and bargain for his parent's attention and love, which he was frightened that he had lost when you left the room while he was in so much distress.
Poor mommy, you are confused with good reason. Your clear intention is to be loving, steady, calm, … and right! You desperately want to guide your son through the choppy emotional waters of toddlerhood. None of this went well tonight, and you don't know whether to follow your heart or your head. I have heard a hundred times about similar downward spirals when parents encounter this problem and opt for some punitive measure (like leaving him alone in his bed without solace) while the child is still hysterical.
Truthfully, grownups may "win" by force if they see this as a power struggle. You risk some pretty negative outcomes that way, though. The child's will may be broken (this is my own history), or a deepening adversarial relationship may become established (my younger sister). Some spirited children may learn over the years tricks for wearing down or fooling their parents to get their way. Rebellion is common when the child gets older.
So if I were in your shoes, and didn't manage to avoid a meltdown for whatever reason (there will always be days like that), I would hold the child firmly but gently if he's hitting or kicking, or sit beside him quietly while he's tantruming, and wait till he realizes you aren't going to react, or abandon him, or punish him. At which point he'll begin to quiet down a bit, and you can tell him that cuddling and story time are still waiting for him if he wants it. To give him as much autonomy as possible, offer him choices instead of an edict. "Do you want a story, or would you like to go to bed?" "Which jammies would you like to wear tonight, the blue ones or the stripey ones?"
You're in for a bumpy but normal ride for a few years, A.. If you can remember that your son's needs are completely natural and legitimate, you'll all come through okay. There are some terrific parenting books that can offer you calm guidance, too. I like Love and Logic.