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 awhile before he gets to 263.

Verlander walked five batters, threw 84 pitches and never threw a pitch over 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, said “I’d rather not” when asked about specifics of his injury but did say he hoped to make his next start, which will include a built-in off day with the Giants traveling to Washington, Detroit and Miami on a nine-game road trip.

While still 0-3, Verlander avoided another loss with help from Heliot Ramos, who drove in the first run in the first on a first-pitch home run off Jeffrey Springs, and the final run on a ground single to left against reliever Tyler Ferguson.

It gave San Francisco a three-game sweep of its former crossbay rivals before a sellout crowd of 40,051.

The Giants are 28-19, with the Athletics falling to 22-25.

Ramos’ home run, off A’s starter Jeffrey Springs, was his eighth of the season. Two pinch-hitters figured in a two-run rally in the eighth off reliever Tyler 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’ single put the Giants ahead as they improved to 28-19. The Athletics fell to 22-25.

“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 .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 type of moments.”

Ramos’ first home run 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 someplace 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 fifth 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 ack 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.”