On October 7, 1848, he was elected professor of mathematics at the University of Wisconsin. He taught and held the position of department chair for many years, while holding other administrative positions. Like Lathrop, he never gave up teaching while performing his administrative functions. During the administration of Chancellor Barnard of the University, from July, 1858, to July, 1860, Prof. Sterling was de facto head of the institution and from the latter date until June, 1867, he was acting chancellor, by authority of the regents. Having previously acted as dean of the faculty, he was, in 1860, continued by the regents in that office until 1865. In 1865 he was elected vice-chancellor, and vice-president in 1869, which office he held until his death. Sterling married Harriet Dean of Raynham, Massachusetts on September 3, 1851. They eventually had three children. Their daughter Susan Adelaide Sterling graduated from the University of Wisconsin in 1879, and after graduate school and other career development, was named assistant professor of German at UW in 1900. Sterling was known for "extending encouragement and generous aid to all who were in need." He was the chief administrator of the university when it first admitted women in 1863, and he was a general advocate for women's equality in education. He and Harriet presided over a women's residence hall beginning in 1881. John Muir credits Professor Sterling for hearing Muir's personal appeal for admission to the school, since Muir did not formally have the educational background due to his work on the family farm in rural Marquette County. As Muir put it:
With fear and trembling, overladen with ignorance, I called on Professor Stirling , who was then Acting President, presented my case, and told him how far I had got on with my studies at home, and that I hadn't been to school since leaving Scotland at the age of eleven years, excepting one short term of a couple of months at a district school, because I could not be spared from the farm work. After hearing my story, the kind professor welcomed me to the glorious University — next, it seemed to me, to the Kingdom of Heaven.
Sterling Hall on the UW campus was named after him in 1921, and is currently the home of the school's astronomy department. It became infamous in 1970 for a bombing which killed a researcher.