Tens of thousands of former slaves were fighting for the United States against the Confederacy by the end of the war.
One was Paul Sandridge.
Born into slavery near Lynchburg, Virginia in 1841, Sandridge was liberated from bondage upon the death of his owner in 1853. As a free man he settled near Portsmouth, Ohio, worked as a farmer, and received an education. The United States began recruiting black soldiers in 1863, and on January 1, 1864, Sandridge enlisted in company C, Twenty-seventh Regiment, United States Colored Troops.
Obtaining the rank of Sergeant, he was seriously wounded while serving and hospitalized at Alexandria, Virginia, where he is honorably discharged this day.
Sandridge returns to Ohio, where he becomes a Baptist (remaining so for the rest of his life) and, over the next several years, tries his hand at farming (again) and business. In 1869 he moves to Dayton, where he works for the U.S. Army in the soldiers’ home. Remaining in the military for the rest of his career, he attains the rank of Captain. Sandridge marries and raises a family.
Source: “Capt. Paul Sandridge,” in Centennial Portrait and Biographical Record of the City of Dayton and of Montgomery County, Ohio, pp. 750-752 (link)