Had it all worked out a little bit differently, Bob Melvin still might have been in a dugout at Yankee Stadium on Wednesday night, trying to navigate his team through the wild-card game and into the ALDS in Boston.

Melvin just happened to be wearing Athletics green and yellow instead of the pinstripes he might have donned had Billy Beane let his manager talk to the Yankees last offseason.

After firing Joe Girardi, Yankees general manager Brian Cashman requested permission to speak with Melvin, who had just gotten a one-year extension through 2019 with the A’s. But Beane, Oakland’s vice president of baseball operations, turned Cashman down, making sure Melvin stayed in an A’s uniform.

For this season, at least, it has worked out well for all involved.

Cashman hired Aaron Boone, who led the Yankees to 100 wins, and Melvin guided the A’s to a more surprising 97 victories.

“I love Bob,” A’s outfielder Mark Canha said before the game. “If you ask anybody in this clubhouse, they’ll probably say the same thing about Bob. We love him. He embraces the madness that is our team and all the energy and the young, dumb guys that we have. We got a lot of energy in here, we got a lot of personalities, and he just embraces it all. He’s our guy. He’s our fearless leader.”

Melvin arrived in Oakland in the middle of the 2011 season, replacing Bob Geren as the interim manager. The former Yankees catcher and Mets scout brought the A’s to the playoffs in each of his first three full seasons before three straight losing seasons led into this year.

Despite the A’s having MLB’s lowest payroll on Opening Day, Melvin has gotten the most out of his players and landed himself squarely in the conversation for AL Manager of the Year.

“The more winning we’ve done, the more [the front office] has gone out and tried to strengthen our team,” Melvin said. “Bringing in these [veteran relievers] and showing this team, and for the most part a younger group until recently, really told them, ‘Look, we feel like you can win,’ and that gives them more confidence.”