but the incident that established Grant firmly on the Republican side was President Johnson's removal of Stanton as the Secretary of War and his treatment of Grant when he discovered that Grant did not support Johnson's handling of that affair.
In late 1865 Grant, by then immensely popular, toured the South at Pres.
Andrew Johnson’s request, was greeted with surprising friendliness, and submitted a report recommending a
lenient Reconstruction policy. In 1866 he was appointed to the newly established rank of general of the armies of the United States. In 1867 Johnson removed Secretary of War
Edwin M. Stanton and thereby tested the constitutionality of the
Tenure of Office Act, which dictated that removals from office be at the assent of Congress, and in August appointed Grant
interim secretary of war. When Congress insisted upon Stanton’s reinstatement, Grant resigned (January 1868), thus infuriating Johnson, who believed that Grant had agreed to remain in office to provoke a court decision.
Johnson’s angry charges brought an open break between the two men and strengthened Grant’s ties to the
Republican Party, which led to his nomination for president in
1868. The last line of his letter of acceptance, “Let us have peace,” became the Republican campaign slogan. Grant’s Democratic opponent was
Horatio Seymour, former governor of New York. The race was a close one, and Grant’s narrow margin of victory in the popular vote (300,000 ballots) may have been attributable to newly enfranchised black voters. The vote of the
electoral college was more one-sided, with Grant garnering 214 votes, compared with 80 for Seymour.
https://www.britannica.com/biography/Ulysses-S-Grant