Williams' exceptional military career began at the very outset of the Revolutionary War, when at 26, he joined a Maryland company of riflemen as a junior officer. He participated in the actions of the siege of Boston and the defense of Fort Washington. He was wounded and captured by the British. He was promoted to Colonel of the Sixth Maryland Regiment while a prisoner of war. Following his exchange, he commanded that regiment at Monmouth before going south. In the south, his regiment was at Camden, Guilford Courthouse, Hobkirk's Hill and Eutaw Springs. He was promoted to Brigadier General at Eutaw Springs.