Barring any physical/medical issues, you should simply relax. It's the hardest thing to do, but will yield the most benefits. Agility, speed, power, and longevity all require relaxation more than any amount of physical strength or finger dexterity. Your spine should be your tree trunk, and try to feel the weight of your forearm at the tips of your fingers as you play. Imagine a fishing hook – the hook is firm, but the fishing line is virtually weightless. The hook is your finger tip, and the line is everything between your finger tip and shoulder. Pretend that you have no muscles between those two points. Keep your shoulders relaxed, and your wrists supple. A good exercise is to play something chordal (like Bach chorales or basic cadences) so that you have multiple "fish hooks" to allow you to relax more. And practice everything slowly, very slowly. Velocity is a by-product of slow practicing.
Try this: In as relaxed a manner as you can, play a forte chord with both hands, any chord, and hold it. Take note of the tension and stiffness at any points between your fingertips and shoulders. Now lift your hands off of the keyboard. Is there much difference in the tension and stiffness? If you don't feel a noticeable reduction in tension while you were holding down the keys, then it means you're too tense, and you're not transferring the weight to your fingertips. It means you're playing "on the surface" of the keys, and using your forearm/hand/finger muscles to hold up your arm even while the keys are depressed. Obviously, you can't maintain this kind of tension for long, and it will dramatically limit your flexibility and endurance, among other things. Play that chord again, and methodically eliminate the tension at each point until the fish hooks are the only things that are firm, and everything else as limp as possible. Do you feel the weight of your arms on your fingertips? If it weren't for your fingertips, your whole arm should fall off the keyboard. Now lift your arms up again. Notice the difference now? This principle applies to even fast playing, and is absolutely crucial for advancement.
Having said all that, I wonder if there is a medical explanation for why you're feeling the level of physical pain and fatigue that you're experiencing. You mentioned that this also happened with your left hand on guitar. Although stiffness, discomfort, and fatigue are not uncommon at certain stages, the kind of pain you're describing leads me to believe something may be wrong. If the above musical prescription doesn't help, then I would suggest seeing a doctor. Best of luck.