Paul Molitor is negotiating a new deal with the Twins that will give him the opportunity to build on a surprising 85-victory 2017 season that ended with a loss Tuesday in the AL wild-card game.

Among the favorites to be AL Manager of the Year, Molitor had a three-year contract that expired at season’s end. Questions about his future swirled even as the Twins rallied in the final two months to make the playoffs.

But Twins Chief Baseball Officer Derek Falvey and General Manager Thad Levine want the 61-year-old to return for 2018, according to a source with knowledge of the team’s plans. The sides were worked on the details of the new contract Thursday and were still doing so early Friday.

The possibility of some change to the coaching staff remains, which could be one of the reasons his deal has not yet been finalized.

Twins coaches met with Molitor, Falvey and Levine throughout the day Thursday, and the talks were generally positive as they discussed everything that went into the club rebounding from a major league-worst 59-103 record in 2016 to 85-77 this season, earning the club its first playoff berth since 2010. The Twins’ season ended Tuesday with an 8-4 wild-card loss to the New York Yankees.

Once the Twins arrived back in the Twin Cities, the goal was to address the futures of Molitor and the coaching staff as quickly as possible.

Molitor has a winning record in two of his three years as manager, but his career record is 227-259 because of the ugly 2016 that led to the dismissal of GM Terry Ryan and the arrival of Falvey and Levine. The new regime agreed when it arrived last November that Molitor would manage the 2017 season, the final year of his contract. But the club waited until after the season to address his future, leading to speculation that Molitor, somehow, would not be brought back.

Upon their arrival last year, Falvey and Levine made minor roster moves, most notably signing free-agent catcher Jason Castro, but eschewed trading second baseman Brian Dozier and pitcher Ervin Santana in the offseason. Both played key roles on the resurgent Twins.

At the July 31 trade deadline, the Twins traded All-Star closer Brandon Kintzler, who was in the final year of a contract, to Washington for a minor league pitching prospect while the Twins were playing on the West Coast. They were three games below .500 and 4½ games behind in the AL wild-card race.

Molitor, a Bruce Springsteen fan, wrote “no retreat, no surrender” on the clubhouse whiteboard. Shortly there­after, with veteran Matt Belisle shifting to the closer’s role, the team went on an offensive surge that lasted through the final two months of the season. The Twins went 35-24 the rest of the way to make the playoffs — despite an injury to All-Star third baseman Miguel Sano, who missed most of the final six weeks of the season.

Molitor, a St. Paul native and former Gophers All-America shortstop, is in the Baseball Hall of Fame after a 21-season playing career and 3,319 hits, 10th best in history. He played his final three seasons with the Twins and had a career-high 225 hits as a 39-year-old.