In response to Congress's call for soldiers at the outbreak of the American Revolutionary War in the spring of 1775, Williams joined a Continental Army rifle unit as a commissioned officer. Soon thereafter, he and his unit marched off to the Siege of Boston. Seeing his first significant combat action in late 1776 at the Battle of Fort Washington, Williams was captured by the British and imprisoned in New York. He was released in early 1778 and returned to the Continental Army as colonel of the 6th Maryland Regiment, a position he had acquired during his captivity. From thereafter, Williams led his regiment through much of the southern campaign, most notably in the battles of Camden, Guilford Court House, and Eutaw Springs. Near the end of the War, Williams was sent by his commanding officer General Greene with documents to Congress and was promoted to brigadier general in 1782.