The young attorney soon entered politics as a Whig and was elected to the Virginia House of Delegates in 1830. During the 1831–1832 session, he took an active part in the campaign to abolishslavery. Then there followed an eight-year hiatus in his political activities during which he returned to the practice of law. In 1840, he was elected to the State Senate, where he served from 1840 to 1844, before returning to the House of Delegates. In 1846, he was elected to the United States House of Representatives.
In March 1849, President Zachary Taylor appointed the Preston Secretary of the Navy. During Preston's tenure in that office, the United States Navy acquired new duties in the course of America's westward expansion and acquisition of California. Trade and commerce in the Pacific Ocean beckoned, and the Stars and Stripes flew from the masts of Navy ships in Chinese waters, while the shores of Japan, then unopened to the west, presented a tantalizing possibility for commercial intercourse. The Navy also was progressing through a technological transition, especially in the area of moving from sails to steam propulsion, and with the improvements in gunnery and naval ordnance. Upon the death of President Taylor, new President Millard Fillmore reorganized the Cabinet and appointed William Alexander Graham Secretary of the Navy. Preston retired from office and withdrew from politics and public life.
Resuming his private law practice, Preston acquired a reputation for being a fine defense lawyer before being sent to France in 1858 to negotiate for the establishment of a line of commercial steamers to operate between Le Havre and Norfolk. The mission to France progressed well, and the project appeared promising until it was brought to naught by the American Civil War.
As states in the lower South seceded from the Union, the pressure mounted upon Virginia to do likewise. Moderate sentiment still held sway through 1860; but, early in 1861, increasing tensions forced Virginians to consider secession. On February 13, 1861, the secession convention met in Richmond and numbered William B. Preston amongst the delegates. As the Confederacy was established and the United States divided into two hostile camps, both sides moved steadily toward open conflict. A special delegation, composed of William B. Preston, Alexander H.H. Stuart, and George W. Randolph, traveled to Washington, D.C. where they met President Abraham Lincoln on April 12. Finding the President firm in his resolve to hold the Federal forts in the South, the three men returned to Richmond on April 15. With the news of the firing on Fort Sumter in South Carolina on April 12, 1861, conservative and moderate strength in the secessionist convention melted away. On April 16, convinced that secession was inevitable, William B. Preston submitted, in secret session, an ordinance of secession. Supported 88 to 55, the Preston Resolution passed, and Virginia left the Union.
Elected C.S. Senator from Virginia in the Confederate States Congress, he served in that legislative body until his death at Smithfield Plantation in 1862. He is interred at the Preston Cemetery in Blacksburg, Virginia, near Smithfield Plantation.