According to Mr. Enzi, Mr. Simpson encouraged him to run for mayor of Gillette, the city to which he had moved only a few years earlier.

“On the way home from that Cody meeting while my wife was driving, I told her what Senator Simpson had said, and that I was thinking maybe I should run for mayor,” Mr. Enzi said in his retirement speech. “It must have come as quite a shock, because she ended up swerving into the barrow pit and then coming back up onto the road.”

At the time, Mr. Enzi said, Gillette was a place where recent discoveries of oil, gas and coal were drawing more and more people — and putting a strain on municipal services. The city, he said, was in need of three things that would become a recurring theme in Mr. Enzi’s political career: budgets, agendas and planning.

“Not the most exciting topics,” he said in his retirement speech.

Mr. Enzi was elected mayor in 1974 and served two four-year terms, during which time he also traveled to and from Washington as a member of the Coal Advisory Committee for the U.S. Department of Interior and served as the president of the Wyoming Association of Municipalities.

He soon set his sights on state politics, joining the Wyoming House of Representatives in 1987, and the Wyoming State Senate in 1991. He was first elected to the United States Senate in 1996. He led the Senate Committee on Health, Education, Labor and Pensions from 2005 to 2007, and was the chairman of the Senate Budget Committee from 2015 to 2021.

In 2009, Mr. Enzi was a member of what came to be known as the Gang of Six, a group of Senate Finance Committee members — three Democrats and three Republicans — who held lengthy negotiations on a health care overhaul. The talks dragged on, and Republicans ultimately backed away from those compromise efforts amid protests from their constituents. The Affordable Care Act would pass in 2010, without support from Republicans in Congress. Mr. Enzi had sought to repeal the legislation.

In 2017, Mr. Enzi was one of 22 senators who signed a letter asking President Donald J. Trump to withdraw from the Paris climate agreement.