No one completely understands how pain works. Actually, a lot is known about pain, but the more we find out the more questions arise. So let's take a simplified view.
Pain is really something you feel in your brain. For example, let's say you hit your finger with a hammer (please don't try this at home). The part of your finger that is damaged has nerve endings in it -- these are little detectors in your joints and your skin that feel things like heat, vibration, light touch from things like the mouse you're holding, and, of course, big crushing shocks like being hit with a hammer. There are different receptors for each of these types of sensations. The damaged tissue in your finger also releases some chemicals that make those nerve endings register the crushing shock even stronger -- like turning up the volume on your stereo so you can hear it better. Some of these chemicals are prostaglandins, and working cells in the damaged tissues make these chemicals using an enzyme called cyclooxygenase 2 (COX-2).
Because of the prostaglandins, the nerve endings that are involved now send a strong signal through nerves in your hand, then through your arm, up your neck and into your brain, where your mind decides this signal means, "HEY! PAIN!" The prostaglandins seem to contribute just a portion of the total signal that means pain, but this portion is an important one. In addition, prostaglandins not only help you to feel the pain of the damaged finger, but they also cause the finger to swell up (this is called inflammation) to bathe the tissues in fluid from your blood that will protect it and help it to heal. Remember this is a simplified version of the pain story; lots of chemicals seem to be involved in this process, not just prostaglandins.
This pathway works very well as far as telling you your finger is hurt. The pain serves a purpose here: It reminds you that your finger is damaged and that you need to be careful with it and not use it until it's healed. The problem is that, sometimes, things hurt without the hammer or for any other good reason. For example, sometimes you get a headache, probably because your scalp and neck muscles are contracted from stress or because a blood vessel in your brain has a spasm. Many people have arthritis, which is swelling and pain in the joints such as the knuckles or knees, and this problem can not only make people uncomfortable, it can damage the joints permanently. And many women have pain in their abdomens during their periods, usually known as cramps, for no known useful reason. These processes appear to involve prostaglandins as well.
Aspirin helps these problems by stopping cells from making prostaglandins. Remember the enzyme, COX-2? It is a protein made by your body's cells whose job is to take chemicals floating around in your tissues and turn them into prostaglandins.
COX-2 can be found in lots of normal tissues, but much more of it is made in tissue that has been damaged in some way. Aspirin, it turns out, sticks to COX-2 and won't let it do its job; it's like a lock you put on your bicycle. The bicycle won't move with the lock on, and COX-2 can't work with aspirin stuck in it. So by taking aspirin, you don't stop the problem that's causing the pain, like the tight muscles in your scalp, or the cramping in your abdomen, or the hammer-damaged finger. But it does "lower the volume" on the pain signals getting through your nerves to your brain.
Next, we'll take a look at what happens to aspirin when it reaches your bloodstream.