Williams had a variety of careers in Detroit. He was elected probate judge of Wayne County, Michigan; in 1842, president of the Bank of St. Clair; in 1843, the owner and editor of the Detroit Advertiser daily newspaper; from 1849 to 1853, postmaster of Detroit.
When Williams arrived in Detroit in 1836, he joined a company in the Michigan Militia and maintained a connection to the military activities of the city for years. In 1847, he was appointed lieutenant of a regiment destined for the Mexican-American War, but it arrived too late to see any action. He also served as the president of the state's military board and in 1859 was a major in the Detroit Light Guard.
On June 26, Williams division was transferred to the Army of Virginia, under Maj. Gen. John Pope, for the Northern Virginia Campaign. In the Battle of Cedar Mountain, Banks's Corps was again up against Jackson, and was again defeated. Williams's division did not reach the Second Battle of Bull Run until after the battle was over.
Williams's division rejoined the Army of the Potomac as the 1st Division of the XII Corps and marched north in the Maryland Campaign to the Battle of Antietam. On the way, troops from the division found the famous Confederate "lost dispatch," Special Order 191, that revealed Gen. Robert E. Lee's plan for the campaign and gave Maj. Gen. George B. McClellan key insights on how to defeat Lee's divided army. The division was heavily engaged at Sharpsburg, once again up against Jackson on the Confederate left flank. The corps commander, Maj. Gen. Joseph K. Mansfield, was killed early at Antietam, and Williams assumed temporary command. The corps suffered 25% casualties in assaulting Jackson, and Brig. Gen. George S. Greene's division was forced to withdraw from its advanced position at the Dunker Church. Maj. Gen. Henry W. Slocum replaced Williams as permanent corps commander immediately after the battle.
Williams's division missed the next major battle for the Army of the Potomac, the Battle of Fredericksburg, because it was engaged in defending the Potomac River in the Reserve. In the Battle of Chancellorsville, on May 2, 1863, Stonewall Jackson's corps executed a surprise flanking movement and smashed into the right flank of the Army of the Potomac, severely damaging the unsuspecting XI Corps. The neighboring division, under Williams, entrenched hastily and was able to stop the Confederate advance before it overran the entire army, but it suffered 1,500 casualties in the process.
In the Battle of Gettysburg, Williams's division arrived on the battlefield late in the afternoon of July 1, 1863, and occupied Benner's Hill, east of the town of Gettysburg. On July 2, the XII Corps took up positions on Culp's Hill, the right flank of the Union line. At this point, due to a command misunderstanding, Henry Slocum believed that he was in command of the "Right Wing" of the army, consisting of the XI and XII Corps. Therefore, Williams assumed temporary command of the XII Corps and controlled it for the rest of the battle. Brig. Gen. Thomas Ruger took command of Williams's division.
On the afternoon of July 2, a massive attack by Lt. Gen. James Longstreet on the Union's left flank caused army commander Maj. Gen. George G. Meade to order Williams to transfer his entire corps to reinforce the left, in the vicinity of Little Round Top. Williams convinced Meade of the importance of Culp's Hill and managed to retain one brigade, under Greene, in their defensive positions. In an heroic defense, Greene and his brigade withstood the assault of Maj. Gen. Edward "Allegheny" Johnson's Confederate division (the "Stonewall Division") throughout the night, until the remaining brigades of the XII Corps returned. Early on July 3, Williams launched an attack against the Confederates who had occupied some of the entrenchments on the hill and, after a seven-hour battle, regained his original line. Unfortunately for Williams, General Slocum was late in writing his official report of the battle, and Meade submitted his report for the army without acknowledging the critical contributions that Williams and XII Corps made to the Union defense.
In September 1863, the Union army in Tennessee was defeated at the Battle of Chickamauga and two corps were sent west to help them as they were besieged in Chattanooga—the XI and XII Corps. (They later were combined due to their small sizes into a new XX Corps, Army of the Cumberland.) Williams's division did not reach Chattanooga, but guarded railroads in eastern Tennessee. However, it did join Maj. Gen. William T. Sherman as part of XX Corps in the Atlanta Campaign and fought with distinction in a number of battles, particularly the Battle of Resaca. Williams was wounded in the arm at the Battle of New Hope Church on May 26, 1864. His division followed Sherman through his March to the Sea and the Carolinas Campaign. In these campaigns Williams lead XX Corps until, following the Battle of Bentonville, Joseph A. Mower was given command. Williams resumed leading his division. During this period, Williams received a brevet promotion to major general on January 12, 1865.
Williams was elected as a Democrat to the 45th United States Congress from Michigan's 1st congressional district, serving from March 4, 1875, to December 21, 1878. For part of his time in congress he served as chairman of the Committee on the District of Columbia.
An equestrian memorial to Williams by sculptor Henry Shrady stands in Belle Isle, in the Detroit River, next to his home town of Detroit. Williams Avenue in the Gettysburg National Battlefield park is named for him.