I have anxiety disorder and panic disorder. Sounds like it could be a panic attack.
Do you feel like something bad's going to happen even if you know it's not? Does your chest tighten up or feel tense?
The best thing you can do is to tell yourself that it's just a panic attack. It's ok to feel that way. It will pass. The worst thing you can do is be afraid of the panic attack or try to fight it. That just makes the panic attack worse or last longer.
If this is something that is happening pretty regularly, you might want to speak to your doctor about it. I take medicines because my disorder is pretty severe, and I can't function without them. I also see a counselor. You may be able to get through them on your own, but definitely reach out for help.
I second much of this advice. (If you aren't sure if they are panic attacks, you should definitely check with your doc to make sure. It could have a physical cause, like a thyroid imbalance.) I used to have fairly regular panic attacks, and the only thing that helped was to embrace them. Try to sit back inside your own head and watch the feelings build, peak, and then subside. You will start to see the pattern, and then you can say, "ah, yes, this is the panic building, I know how this works," and it becomes less scary (and shorter lived!) I still get them from time to time (especially since getting pregnant,) but now it is generally about three minutes of me telling the panic attack "yeah, I know you. Come on in and have a cookie," and then it is over. The more you fight it or try to block it, the more power you give to it.
And if you continue to have problems with them, absolutely you should reach out for help. They are common and nothing to be ashamed of!
Good luck! :)