@wojciech
Hi!
Sorry to hear that!! It's difficult to say if you're making a mistake in terms of how you're fretting the chords/holding the guitar without seeing a picture or film of your hand when playing - but if it's a problem that keeps occurring I'd go to someone with medical background to or physiotherapy to take a look at your hand problems. I've always gotten the advice to stop playing if my hand hurts, and then rest - so that you don't get even more problems. Does this happen right away when you start playing or after a few minutes or even an hour?
Kind regards/E