Was there a formal process, or did it just happen for whatever reason... ? Fill me in here!
EDIT: I get that the topic is broad (I always hear that about the middle ages; 1000 year window, lots of different states and all that), but I'm hoping people that study this can provide a clear and concise idea of the way things might have worked.
I believe you're mistaking a serf for a slave. However, it's true that, technically speaking, their legal status was not what we would consider the status of a 'freeman' nowadays. Although the Allgemeine Landsrecht für die Preussichen Staaten - ALR (General State Laws for the Prussian States) could hardly be considered a code from "the middle ages" (remember, we're talking about an age that spans roughly from the fifth to the fifteenth century, so it's pretty hard to nail a precise answer to this question) I think it would still be a fairly enlightening reading to you, since Frederick II intended to codify in a very clear, understandable and logic way the core elements of society (i.e. from what was considered to be a person to the definition of a 'peasant' or serf - Bauer -, a 'Bürger' - which would later be the general german expression for citizen - and a 'noble' - Adel). Just to give you an example, the first paragraph of the seventh Title of the ALR defines a 'peasant' (Bauer) as residents of the plains, who work with farming and wood cutting, as long as they are not removed from such a status by birth, public service (Amt) or other special rights. So this particular rule already tells us that you could cease to be a serf, or peasant by birth or joining 'public service'. The ALR also tells us (eighth paragraph, ninth Title), for instance, that if a woman from a lower Status (Stand) married a man from the nobility, some rights from this Status could be extended to her, as long as the marriage wasn't considered contrary to law. I'll provide the reference to the full document here. Unfortunately, it's in german only and I could not find an english translation from it. Finally, it's also to be stressed that this is only a tiny example for a very broad topic of discussion.