Following the U.S. Civil War, regiments of African-American men known as buffalo soldiers served on the western frontier, battling Indians and protecting settlers. The buffalo soldiers included two regiments of all-black cavalry, the 9th and 10th cavalries, formed after Congress passed legislation in 1866 that allowed African Americans to enlist in the country’s regular peacetime military. The legislation also brought about the creation of four black infantry regiments, eventually consolidated into the 24th and 25th infantries, which often fought alongside the 9th and 10th cavalries. Many of the men in these regiments, commanded primarily by white officers, were among the approximately 180,000 African Americans who served in the Union Army during the Civil War.

https://www.history.com/topics/buffalo-soldiers