In 1820 Doty was chosen by Lewis Cass, governor of Michigan Territory, to serve as secretary on his expedition to the headwaters of the Mississippi River. The expedition “explored the upper lakes in canoes, stretched 4,000 miles, and enacted treaties with regional Indian tribes.” In 1823, a new federal judicial district was created for northern and western Michigan Territory, covering what is now the state of Wisconsin and the Upper Peninsula of Michigan. Doty was appointed as the federal judge for the district by President James Monroe, and, because he was required to live within his district, Doty moved from Detroit to Prairie du Chien, Wisconsin in 1823. Doty regularly held court at Prairie du Chien, Green Bay, Wisconsin, and Mackinac Island, Michigan. He also served as postmaster at Prairie du Chien from 1823 to 1824. In 1824, Doty moved to Green Bay, where he lived until 1841. Doty remained the district judge until he was replaced by David Irvin in 1832.
Doty served as a member of the Michigan Territorial Council from 1833 to 1835, where he began petitioning Congress for the division of Michigan into two parts. He said that the growing number of residents in Wisconsin was not taken into consideration by the territorial government in Detroit. Doty claimed that votes sent by residents west of Lake Michigan could not be sent to Detroit in time to be counted, and that the residents in Lower Michigan cared little about the affairs west of the lake. In 1835, Doty campaigned to represent western Michigan Territory as a delegate in Congress, but he lost in a three way election to George W. Jones. Both Doty and Jones were running as Democrats, but Doty had little loyalty to any political party. He usually associated himself with whichever people were most popular at the time. His wishes were partially granted when the Governor of Michigan Territory created a separate legislature to govern the western part of the territory as Michigan prepared for statehood. After losing the election, Doty turned to land speculation and bought thousands of acres of land across the state, some of which he began developing into the city of Madison, Wisconsin.
In 1836 Wisconsin Territory was officially created. Doty had hoped to be appointed governor, but President Andrew Jackson appointed Doty's rival, Henry Dodge, instead. With no public title, Doty worked to improve his land holdings in what would become the city of Madison. Doty had this land surveyed, and made plans to create a city. To gain recognition for the city, Doty bribbed the new territorial legislature to select his proposed city as the capital of Wisconsin. A temporary capital had already been established at Belmont, Wisconsin, but its distance from Milwaukee and Green Bay made many legislators dissatisfied towards Belmont. It made it likely that the capital would be moved. In November 1836 he successfully convinced the territorial Legislature to select his proposed city as the capital and to name him its building commissioner
In 1838, Doty was elected as Wisconsin Territory's congressional delegate, defeating George W. Jones in a rematch of the 1835 election. in spite of being elected as a Democrat, Doty formed personal friendships with several Whigs in Washington, D.C. In