SAN FRANCISCO -- Jonathan Schoop hit a three-run homer in the ninth inning and the Baltimore Orioles overcame a six-run deficit to give the struggling San Francisco Giants another deflating loss, 8-7 on Sunday.
Matt Wieters had a career-best five hits, including a triple, and the Orioles won for the third time in four games and concluded a 10-game trip with an even record. Baltimore trails Toronto by half a game in the AL East.
Schoop homered off Santiago Casilla (2-4) with two outs after Manny Machado singled and Mark Trumbo walked. Baltimore trailed 7-1 after six innings but got two runs in each of the seventh and eighth innings.
The Giants led the NL West by 6 1/2 games at the All-Star break but have gone 9-18 since. They entered Sunday with a one-game lead over the Dodgers.
Brad Brach (7-1) pitched a scoreless eighth inning for Baltimore.
Giants starter Johnny Cueto extended his streak of winless starts to six. He allowed one run on eight hits and one walk in 6 2/3 innings.
Brown had a two-run single that highlighted a four-run fifth inning. Pagan extended his hitting streak to 12 games.
Orioles closer Zach Britton pitched a scoreless ninth inning for his 37th save in 37 chances, extending the longest streak for a left-hander in major league history.
Pence homered off Wade Miley in the fourth inning, his first since a nearly two-month stint on the disabled list that ended July 30 - Pence's last homer was on May 18.
Miley was acquired from Seattle on July 31 and remains winless with his new team after allowing seven runs (six earned), eight hits and two walks in 4 1/3 innings.
Derek Law allowed one hit in a scoreless 2/3 of an inning in the eighth that extended his consecutive streak of scoreless outings to 19.
Orioles: Manager Buck Showalter took note of CF Adam Jones' return to the lineup Sunday without complaints after getting hit on his finger and knee trying to bunt in the sixth inning of Saturday night's game. "It's an honor to watch him post up every day," Showalter said.
Giants: C Buster Posey was scratched from the lineup just before first pitch with lower back tightness. ... OF Mac Williamson, on the disabled list since Aug. 1 with a left shoulder strain, began a rehab assignment with Triple-A Sacramento. ... RHP Cory Gearrin, out since July 6 with a right shoulder strain, pitched for a second straight day on Saturday for Triple-A Sacramento. He'll continue his rehab assignment as the Giants consider the timing of his return.
Orioles: RHP Yovani Gallardo will pitch the series opener with Boston on Tuesday. Gallardo is 1-3 with a 4.70 ERA in his last eight starts but has had two straight quality starts, allowing three earned runs in 12 innings over that stretch.
Giants: Newly acquired LHP Matt Moore will make his home debut in a series opener with Pittsburgh. He is 0-1 with a 3.00 ERA in his first two starts with San Francisco and 7-8 with a 3.99 ERA in 23 combined starts with the Giants and Tampa Bay.