ANAHEIM — With the Yankees and Angels knotted at one on Wednesday, Austin Wells stepped to the plate with the bases loaded and two out in the 10th inning.

The Bombers, or at least their fans, would have wanted just about anybody else up in that spot not too long ago, as Wells was one of the worst hitters in baseball over the first few months of the season. But the left-handed hitter’s fortunes have changed over the last month-plus, and his success continued when he grounded a two-run single in extras on Wednesday.

The knock capped a six-pitch at-bat against Luke Murphy and jump-started a five-run rally in the 10th inning. That set the second-place Yankees up for a 6-3 win and allowed them to gain a game on the first-place Rays, who lost earlier in the day.

Not a bad night for Wells, who didn’t enter the game until the eighth inning.

“He’s making a living doing that right now, coming off the bench and getting fat,” said Aaron Boone, referring to a few other recent games in which Wells made an impact off the bench.

Sub or starter, Wells has been helping at the plate for a little while now. While he’s hitting just .190 with a .597 OPS overall after going 2-for-2 on Wednesday, he entered the series finale with a .245 average, a .793 OPS, five doubles, six home runs and 16 RBI over his last 42 games.

“You feel like he’s that threat again down there, and that’s massive,” Boone said of Wells, who hit .148 with a .468 OPS, four homers and 10 RBI over his first 62 games of the season. That stretch included a stint on the injured list for cervical headaches, the result of taking a beating behind the plate.

In retrospect, that time on the shelf was a blessing in disguise, as Wells was able to work with Jarret DeHart, the Yankees’ hitting director, and other coaches while on the IL and during a rehab assignment.

“It was just kind of the understanding of where my swing was at, and then how I was missing, whether it was actually missing or fouling stuff off I should be hitting,” Wells said. “So that awareness has helped allow me to be a little bit more accurate with the bat and the timing.”

Boone has repeatedly referenced that work and how much better Wells looked after his IL stint over the last few months. While the backstop didn’t get instant results after being activated on June 21, the manager immediately noticed a difference.

“I felt like when he came back off the IL, it wasn’t good yet, but I could see the move evolving and getting better,” Boone said. “Then he started to get a little bit of results, slowly but surely. But it was a process of getting to a point where he’s getting a better load and getting into better hitting positions, ultimately to get his swing off. And we know he’s a very capable offensive player. So it took a while, but I felt like the seeds of this were when he came off the IL.

“It looked better, and he’s continued to get better, and he’s been really good for us.”

The Yankees have to hope that that continues, as Wells’ relative rebound at the plate — he hit 21 homers last year and had an OPS over .700 the last two seasons — has lengthened a lineup that hasn’t been at full strength for most of the season.

Getting Aaron Judge back soon should help with that, but so will more positive contributions from Wells at the bottom of the order.

“He looks really good, and the results are showing,” said Cody Bellinger, who followed Wells with another RBI single in the 10th on Wednesday. “It’s huge for the team.”

Still, even with his turnaround, Wells reiterated that catching is his No. 1 job. His work behind the plate — he’s a top-10 framer and has handled one of the best pitching staffs in baseball — helped him get through his offensive struggles. He’s not losing sight of that just because he’s started to swing the bat well.

“Obviously, definitely not how you expect it to go or draw it up, no doubt,” Wells said of his scuffles earlier in the season. “Definitely the worst stretch I’ve had ever, probably, in my life. But like I’ve said the whole time, being behind the plate and contributing there is my No. 1 job. So our staff’s been incredible this year, and that’s helped a lot with me mentally, just knowing that we’re doing a lot of really good stuff on that side of the ball.

“It allows me to get up for my next at-bat and not feel terrible.”