SAN FRANCISCO — Justin Verlander came into the season with 262 wins, the most in Major League Baseball.

Depending on how he’s feeling after struggling through four innings Sunday as the Giants came back in the bottom of the eighth inning to beat the Athletics 3-2 at Oracle Park, it may be a while before he gets to 263.

Verlander walked five batters and threw 84 pitches, topping out at 93 miles per hour.

“I was dealing with something physically that I was able to work through,” Verlander said. “It was kind of affecting my velocity and mechanics.”

Verlander, 43, did not want to discuss the specifics of his injury but did say he hoped to make his next start, which could come next weekend when the Giants are in Washington to play the Nationals from Friday to Sunday. The Giants are off Thursday, giving Verlander an extra day of rest.

Verlander (0-3) avoided another loss with help from Heliot Ramos, who drove in the first run in the first inning on a first-pitch home run off A’s starter Jeffrey Springs. Ramos also drove in the go-ahead run in the eighth on a groundball single to left against reliever Tyler Ferguson.

Ramos’ production helped the Giants (28-19) finish a three-game sweep of the Athletics (22-25), their former crossbay rivals, before a sellout crowd of 40,051.

Ramos’ home run was his eighth of the season. Two pinch-hitters figured in a two-run rally in the eighth off Ferguson, with LaMonte Wade Jr. hitting a triple to right center and scoring on Patrick Bailey’s ground single to center.

After a sacrifice bunt by Christian Koss, Ramos’s single put the Giants ahead.

“I know LaMonte has been going through some things, but I think he’s getting great at-bats,” Ramos said. “He’s had a lot of bad luck. And Bailey, I know he’s got a lot of games to come through. After what they did, I felt the pressure to come through.”

The pinch hits by Wade and Bailey were from two hitters who have been at less than their best offensively. Wade is hitting .165, and Bailey is hitting .185.

“There’s certain at-bats that can be huge for you,” manager Bob Melvin said of Wade. “He’s had a history of being able to pinch hit, and even though it hasn’t been great for him, I think he’s ready for those types of moments.”

The home run by Ramos left the bat at 111.2 miles per hour, a laser that cleared the fence in center.

“I knew he wasn’t throwing super hard so it was like, if it’s middle-middle, that’s all mine,” Ramos said. “I ran out of the box thinking double or triple. I thought it was going to go off the wall.”

Wade said he was only looking to hit the ball hard somewhere on his triple and has played too long to let the slump get into his head.

“Trust your process. This is my sixth season,” Wade said. “I know the ebbs and flows. You’ve got to keep coming in, put in the work, and trust and believe that they’ll fall.”

After Ramos’ initial blast, Springs retired the next 20 hitters before Matt Chapman singled with two out in the seventh. A’s manager Mark Kotsay then went to right-hander Justin Sterner, who walked Willy Adames before he retired pinch hitter Mike Yastrzemski on a fly to center to retain a 2-1 lead.

In 7 2/3 innings, Springs threw 84 pitches, 54 of them strikes, with no walks and five strikeouts.

After Verlander appeared to right himself in a 13-pitch, 1-2-3 third inning, he ran into trouble after getting the first two outs in the fourth.

“I thought maybe I’d figured out a way to navigate the mechanics and throw the ball semi where I wanted to,” Verlander said. “But the fourth was pretty much more of the same. So that was pretty frustrating.”

Luis Urias doubled over the head of Ramos in left, with Verlander walking the No. 8 and 9 hitters, Max Schuemann and Jhonny Pereda. Lawrence Butler followed with a first-pitch two-run single to center, driving in Urias and Schuemann for the two runs against Verlander.

By that point, Verlander was up to 84 pitches, 41 strikes and five walks. When the fourth opened, Spencer Bivins was on the mound, and Verlander was still looking for his first win as a Giant in 10 starts.

“There are days when you feel better than others,” Melvin said. “At the pitch count he was at, I didn’t want to put him back out there and go well over 100 potentially. I think it was one of those days when he didn’t feel great.”

After Verlander’s departure, Bivins (two innings), Eric Miller, Randy Rodriguez and Ryan Walker held the A’s scoreless, with Walker getting his eighth save. Rodriguez (3-0) was the winning pitcher, with Ferguson (0-2) taking the loss for the Athletics.

Attendance for the three-game series — all sellouts — was 121,611. The A’s, by contrast, have drawn 213,500 in 21 home dates. Melvin managed the A’s from 2011 through 2021.

“The A’s are always the A’s, and it’s always going to be a rivalry here,” Melvin said. “They don’t have Oakland in their name, but it’s still a raucous crowd, probably as we get all year. It’s just different level stuff for me.”