SAN FRANCISCO — Dodgers manager Don Mattingly was surprisingly upbeat after his team’s third straight one-run loss to the division-leading Giants.
Catcher A.J. Ellis was having none of it, no matter what the circumstances were.
Los Angeles scored three times in the eighth inning but left the tying and go-ahead runners on base in a 4-3 loss to San Francisco on Sunday night that extended the Dodgers’ losing streak to five against the defending World Series champs.
“It is really hard to talk about moral victories after being swept,” said Ellis, who had two hits and scored a run. “We kind of had our slow spell at the beginning of the year ... and now we have to spend the rest of the year playing the way we’re supposed to play.”
The Dodgers couldn’t get out of AT&T Park fast enough. They were the only visiting NL team with a winning record at the Giants’ waterfront ballpark before the series, but are now 60-60 since the stadium opened in 2000.
It didn’t help that Mattingly had to scratch first baseman Adrian Gonzalez from the lineup with a sore neck less than an hour before the first pitch. Los Angeles also was without injured second baseman Mark Ellis and shortstop Hanley Ramirez, who went on the disabled list Saturday.
Still, Mattingly sounded optimistic after seeing his team nearly come back from a 4-0 deficit before falling short.
“I’m really not disappointed in how we played,” Mattingly said. “I feel better about our club walking out of here right now than I did walking in. We played them tough the whole series.”
Just not tough enough.
Since beating San Francisco on opening day, Los Angeles has lost five straight to the Giants and is 5½ games behind them in the NL West.
Dodgers rookie Hyun-Jin Ryu (3-2) has been one of Los Angeles’ most consistent pitchers, except against San Francisco, which has handed him both of his losses.
He gave up 10 hits and three runs while taking the loss in his majors debut on April 2, then allowed eight hits and four runs over six innings in the rematch.
“My main issue today was not being able to get (Hunter) Pence out,” Ryu said through an interpreter. “It came down to that. He was the only one that got me today.”
Pence doubled twice and drove in four runs to snap out of a season-long funk with runners in scoring position, while Matt Cain (1-2) pitched into the eighth inning for his first victory of the season to complete a series sweep for the Giants.
Cain, who pitched six shutout innings against Los Angeles on opening day, gave up one run and five hits in 7 1-3 innings and allowed only one runner past second base while ending the longest winless drought of his career.
The Giants opened with three straight singles off Ryu in the first, but the Dodgers right-hander got out of it allowing only one run. Marco Scutaro scored on Pence’s fielder’s choice grounder after Buster Posey hit into a force-out at home. Ryu then retired Francisco Peguero on a fly ball to end the inning.
Pence, who was hitting just .211 with runners in scoring position, doubled Scutaro home in the third then hit a two-run double off Ryu in the fifth to drive in Pablo Sandoval and Posey.
After Cain walked Matt Kemp with one out in the eighth, Ellis singled off reliever George Kontos and Juan Uribe walked. Gonzalez followed with a pinch-hit two-run single to center and Uribe scored on an infield hit by Dee Gordon to make it 4-3. Jean Machi got pinch hitter Jerry Hairston to ground out with the tying run at second base to end the inning.
“He did what he was supposed to do and that is shut us (down),” Kemp said of Cain. “We just didn’t get any hits.”
Cain, who struck out four and walked three, had not won since Sept. 26, 2012. It’s also the first win by any San Francisco starter since April 21 — an 11-game stretch.
Sergio Romo worked the ninth for his 12th save, tied for most in the majors.
NOTES: Hairston was not in the Dodgers starting lineup because of a sore groin. ... San Francisco CF Angel Pagan did not play because of a strained hamstring and is questionable for Monday’s series opener against Philadelphia. ... Chris Capuano (0-1) is scheduled to come off the disabled list and start for Los Angeles on Monday against Colorado.