I have a 29 inch Iron-Horse/Sunday 24 speed. My back wheel locked up, when I got off the wheel would move side to side.
I thought I lost bearings, took my freewheel apart and clean. Doesn't look like I lost any bearings, but not sure.
If the wheel wobbles in the frame (and the QR or through axle is tight), or with the wheel out you can wobble the axle in the hub: at least one of the bearings has a problem, or perhaps the axle broke or the hub shell has failed. If you have a serviceable cup and cone bearing hub, one of the cones may simply have come loose.
The way forward depends on what kind of hub you have. Without more info on the specifics of you hub we can't provide further advice.