Wharton entered politics in late 1879, when he first ran for office. In December of that year, Boston elected a Democratic mayor,
Frederick O. Prince, but Republicans won the majority in the Common Council (later known as the City Council); among the elected Republicans was William F. Wharton. He was appointed to two committees: finance and ordinances. He became known for his work revising and updating city ordinances, and by 1884, after having been re-elected twice, he was named chairman of the ordinances committee. Wharton was well-regarded by the city's political establishment: the
Boston Herald praised his work on the council, saying he had become "one of the most influential members of the lower branch of the city government." Subsequently, Wharton continued to move up in Massachusetts politics, getting elected to the House of Representatives in 1885. He served there until 1888, becoming the chairman of the rules committee as well as working on issues related to the railroads. ==National politics==