Jim Johnson (3-7) gave up a game-tying hit to Hunter Pence with no outs in the ninth and then worked out of the jam to gain the victory.
"That's why we trust him," Showalter said. "He kept competing and didn't give in."
Orioles starter Chris Tillman threw eight stellar innings, striking out a career-high nine, giving up one run on four hits and walking one.
"It felt really good. I got into a groove early and everything was working for me," Tillman said. "These guys are fun to watch. I just need to throw strikes and let them go to work."
Brandon Belt had two hits, including a home run, for the Giants, who have lost five of seven. Javier Lopez (1-2) allowed all three runs in the 10th to take the loss.
Tillman was on his way to becoming the first Orioles pitcher to win eight road games in a season before Johnson blew his first save since July 1.
"The way he pitched he deserved the win," Johnson said. "I didn't do my job. I didn't think I threw that many bad pitches. I went out there with good stuff. A couple of balls got through."
Ryan Vogelsong, who was reinstated from the 60-day disabled list before the game, allowed two runs on six hits over six innings. He walked three and struck out four.
"I missed it. It felt great to get back out there and pitch again," Vogelsong said. "I just tried to think about the stuff I need to do to make pitches."
Tommy Hunter got the final three outs for his third save in four chances.
Machado recorded his 41st double of the season with one out in the first. Jones singled him home to put the Orioles ahead, 1-0.
Hardy led off the second with his 20th homer, giving Baltimore a 2-0 lead.
Vogelsong, in his first appearance since May 20, settled in afterward. After allowing six hits in the first three innings, he retired 10 of the final 12 batters he faced.
"He pitched well," Giants manager Bruce Bochy said. "He got better as he went along and gave us six good innings. He did a great job. That's a nice effort."
Belt hit his 13th home run of the season and second in as many days, a solo shot, with two outs, to the deepest part of the park.
Tillman retired 16 in a row after walking Pablo Sandoval in the second. He struck out the side in the second and the first two batters he faced in the third.
Machado doubled off Brandon Crawford's glove with one out in the 10th. After getting Nick Markakis on a comebacker, the left-handed Lopez walked Jones intentionally and got ahead of Davis 1-2 before giving up the two-run double. Wieters followed with an RBI single.
The Giants hit home runs in successive home games for the first time since May 25-29, a three-game stretch. ... RHP Jean Machi was optioned to Triple-A Fresno to make room for Vogelsong, who was reinstated from the 60-day DL. ... Giants RHP Guillermo Moscoso will pitch out of the bullpen with Vogelsong back in the rotation. ... Giants IF Tony Abreu (left knee bursitis) will begin a rehab assignment with Triple-A Fresno on Sunday. ... The Elias Sports Bureau reported RHP Tim Lincecum became the first Major Leaguer since Johnny Vander Meer threw back-to-back no-hitters in 1938 to surrender one hit and pitch more than six innings in his first win after throwing a no-hitter. ... Orioles IF Chris Davis became the first hitter with 40 or more home runs to appear in AT&T Park since Arizona's Mark Reynolds on Sept. 21, 2009. Before that it was Barry Bonds in 2004. ... Hardy became the third O's SS to record three consecutive seasons of 20 or more HRs, joining Miguel Tejada and Cal Ripken, Jr. ... O's RHP Jason Hammel (right flexor mass tightness) received a cortisone shot from Dr. James Andrews.
Copyright by STATS LLC and The Associated Press
SAN FRANCISCO, CA - AUGUST 09: Chris Tillman #30 of the Baltimore Orioles pitches against the San Francisco...