The nut was frozen onto the stud. It needed to be freed up by soaking in Penetrene for days, rather than just repeatedly wiggled back and forth, which has fatigued the stud until it broke.

Can we see the far side of the object the stud is screwed into please? It is possible that what has broken is a bolt rather than a stud, and it has a bolt head on the far side. If so the situation can still be remedied, provided you soak it in Penetrene before you go any further. If you don't soak it, you'll probably break off the bolt head as well, and make the situation worse.