It sounds like the shift fork is broke. The fork rides in a collar in the gear that shifts the gear position in and out of four wheel drive. The detent (the part that holds it in or out of gear) is part of the shift lever itself. That is why it will shift in and out of 4 wheel drive especially on an incline. The gear will slip back being that it is no longer attached to the shift lever.
If I remember right on that model. The lever has linkage that goes down to the center of the tractor where it links to the shift lever itself and you may be able to repair this fairly easily by removing the drive shaft and dropping the assy. from the bottom. Don't forget to drain the fluid before removing the assy.