He woke up during the wet dream and found that a few drops of maniy had been emitted, so he masturbated; did that invalidate his fast?
Question

I went to sleep after Fajr prayer, then I woke up as I was having a wet dream, but only a few drops of maniy had come out. I felt pain in my testicles, so I completed the ejaculation with my hand. Did that spoil my fast?
Praise be to Allah.Masturbation is forbidden in Ramadan and at other times, and it renders the fast invalid.
It says in Kashshaaf al-Qinaa‘ (2/318), discussing things that invalidate the fast:
… or if he masturbates, and emits maniy or madhiy. That is because if the fast is spoiled by kissing that results in ejaculation, then it is more likely to be spoiled by that.
If he does not ejaculate, then he has committed a haraam action, but he has not spoiled his fast. End quote.
What is most likely to be the case is that the fast is not spoiled by emission of madhiy, as has been explained previously in the answer to question no. 49752.
Based on that, what you did by masturbating is haraam, and your fast was spoiled by that. You have to make up that day, and also repent.
For more information, please see the answers to questions no. 71213 and 207243.
And Allah knows best.