Sounds like you could have the start of an RSI (repetitive Strain Injury). Rest is often recommended, but it's not the only solution. Too much rest is the slowest way to recover from most sports style injuries.
I'd try to warm up slowly, perhaps use warm water to soak you hands before playing. Limit the time you play difficult passages.
If it hurts STOP, take a break, and then try playing something that doesn't cause the pain.
Self help includes using ice packs (frozen peas are good) for 5 minutes on the injured spot 3 times per day. Don't play on the day you do this (oh, and don't eat the peas once they,ve been thawed and refrozen..mark the bag!). Be careful and don't leave it more than 10 minsor you might freeze the skin...not nice!
Anti inflamatories / pain killers (Ibuprofen) can help, but don't use them to 'mask' the pain so you can play. That's just switching off your body's own warning of damage...ie pain. That would make it much worst and could cause a long term problem.
Build slowly your intensity of playing difficult passages. Use pain as a sign you went too far, take a day off, use the ice, then go back to easier stuff and build it up again.
Every so often (like once a month), make sure you completely rest (no piano) for at least 2 - 4 days, depending on how many hours a day you practice. Give your body a chance to repair and relax.
It's about listening to your body. It will tell you (as it just did) if you're overdoing it.
I'd suggest checking out any tension you may have in your hands, wrists, arms, shoulders, back, neck or mind while playing. Relaxation is the key, combined with progressive resistance. This story explains:
A young boy on a farm picks up and carries a baby bull on his shoulders each day. Because it's a baby, he can carry it easily. As the weeks and months pass, the bull grows, steadily, as do the boy's muscles. The body compensates for SMALL and gradual increases in resistance by growing stronger (or more flexible if stretching is the aim). After two years the boy can lift the full grown bull as easily as he lifted it as a baby. Just as the bull didn't notice itself growing little by little, so the boy didn't notice the incremental increases in his strength.
Good luck.