A side stitch is thought to be a muscle spasm of the diaphragm. Some say it may actually be a spasm of the supporting ligaments, but either way, treatment and prevention are the same. The diaphragm muscle is instrumental in breathing and it can get fatigued like any other muscle. A spasm affects the muscle, supporting ligaments, tendons, and the surrounding connective tissue, known as fascia.
When a side stitch occurs, stop running and take some deep breaths. Then, press your first two fingers in and slightly upward directly where it hurts and hold for about 10 seconds. While pressing in and up, take more deep breaths. You can continue this process of pressing in and up, all around the edge of your ribs up to your sternum.
You can also try stretching to relieve the cramp. Most side stitches are on the right side, so raise your right hand and lean to the left to stretch. Do the opposite if your stitch is on the left side. When the stitch subsides, start walking, then slowly begin running and gradually pick up your pace.
To prevent side stitches, avoid eating one to two hours before running, increase your water intake throughout the day, and warm up well before running fast.