Crude-oil futures ended Friday trade on a decidedly upbeat note, settling above $60 for the first time in more than two years to wrap up 2017.

West Texas Intermediate crude on the New York Mercantile Exchange US:CLG8 finished up 1%, or 58 cents, to $60.42 a barrel. That represents its first close above $60 since June 23, 2015, according WSJ Market Data Group. U.S. benchmark oil is up 12.5% in 2017, nearly 17% this quarter, 5.3% for the month, and 3.3% this week.

March Brent UK:LCOH8 rose 71 cents, or 1.1%, to $66.87 a barrel. The international benchmark for crude has gained 18% this year, more than 16% over the last three months of the year, 5.2% for the month, and 0.6% for the week.

The market has improved amid optimism about years of oversupply finally ebbing, capped by rising demand and the production-limit deal, led by the Organization of the Petroleum Exporting Countries, being extended through 2018. Both oil contracts rallied to end at 2½-year highs.

Moves for crude prices came as Baker Hughes on Friday reported a small drop in rig counts for the week, with rigs drilling for gas down by two to 182, while those drilling for oil remained unchanged at 747. Over the year, however, total rigs have climbed by 271 to a total rig count at 929.

On Thursday, the market took cues from inventory reports that showed a steady decline in U.S. crude stocks. The U.S. Energy Information Administration reported that domestic-crude supplies fell by 4.6 million barrels for the week ended Dec. 22, compared with a 6-million-barrel drawdown reported by the American Petroleum Institute late Wednesday.

Meanwhile, natural gas US:NGG18 for February jumped 3.9 cents, or 1.3%, to settle at $2.9530 per million British thermal units, after surging 6.4% on Thursday, posting the biggest daily rise since Dec. 21, 2016, according to FactSet. Natural-gas futures, however, have declined 21% in 2017, retreated 1.8% on the quarter, fell 2.4% on the month, but an 11% surge this week, amid freezing weather, helped mitigate more brutal losses.

January heating oil US:HOF8 rose by about 2.34 cents, or 1.1%, to $2.0755 a gallon, marking a fresh 52-week high and the highest settlement since Feb. 27, 2015. Futures have gained 22% this year, about 15% this quarter, 10% in December, and 5.4% gain on the week.

Arctic cold air has been chilling portions of the U.S., with forecasts calling for a continuation of that weather into the first week of January. Record-cold levels were set in Minnesota and Michigan on Thursday, according to The Weather Channel. Cold weather could support further buying of natural gas and heating oil.

January gasoline US:RBF8 rose 0.62 cent, or 0.4%, to $1.7992 a gallon. Gasoline futures are up 8.1% in 2017, 12% over the past three months, 4.1% on the month, with a 2.1% advance this week.

— Biman Mukherji contributed to this article