Over the course of the last four centuries or so, African Americans as a group (if we can truly lump all African Americans into one huge group) have had to endure a long process that has led to them being as free as they are today. This process did not end with the end of slavery but, instead, has continued (arguably) until the present.
Beginning in the 1620s, there were African American slaves in what became the United States. Over time, some of the states of the US created legal and social systems that completely subordinated African Americans. From these depths of subjugation, African Americans had to work hard to become free.
Many slaves worked to become free. They tried to escape and resisted their owners in other ways. Freedom from slavery came with the Civil War. African Americans helped with this war in a variety of ways, helping to win their freedom.
However, this freedom was to some degree illusory as blacks in the South (in particular) continued to be subjugated. Blacks then had to fight to gain true freedom through such means as the Civil Rights Movement of the 1950s and 1960s. Some would argue that blacks are still having to fight to become truly free from racism and discrimination today.