Slaves before the Civil War gained their freedom in one of three ways. The most obvious, and most dangerous, was to simply run away. The Underground Railroad assisted them to escape to the northern states, and eventually all the way to Canada. Other slaves managed the journey on their own. But for every slave who gained their freedom this way, there were too many who were recaptured and dragged back into captivity. And as the Civil War approached, laws about runaways made even the northern states a perilous sanctuary. The laws permitted slave hunters to take escaped slaves( and not infrequently free Blacks accused of being runaways) back to the South.
The second way a slave could gain their freedom was by emancipation. Basically, this meant that their owner legally documented that he or she was giving the slave their freedom. This was a fairly common occurrence., with many owners leaving such instructions in their wills. Of course, it could be abused too. After all, "rewarding" a slave with emancipation when they were getting to be elderly and unable to work efficiently was a nasty means of cost savings. This sort of abuse did not seem to be very common or approved of, even in a slave society.
The third method of freedom involved the slave purchasing their own freedom. While technically everything a slaved owned belonged to his or her master, in practice slaves were usually allowed to earn money on the side. Those slaves with skills, such as blacksmith, silversmith, carpentry, or other forms of craftsmanship normally could do jobs after they finished their master's work, and keep the money. By saving this extra income, a slave could eventually save enough to purchase their own freedom, and even that of their families. This was a process of years, if not decades, though, and required great financial discipline, as well as an owner who would allow the slave to thus purchase his freedom.