OAKLAND, Calif. - In the final month and a half of the season, Royals pitcher Jorge Lopez turned around what had been a frustrating season.

In one three-batter span on Tuesday night, the Oakland Athletics turned upside down what would've been Lopez's most encouraging outing.

Lopez gave up two runs, including a solo home run, in the bottom of the seventh inning in a 2-1 loss to the Athletics in front of an announced 14,992 at Oakland Coliseum.

Royals third baseman Hunter Dozier and outfielder Ryan McBroom each doubled, and Nick Dini (sacrifice fly) drove in the club's lone run. Athletics pitcher Brett Anderson, who made his 30th start of the season (a career high), allowed one run on five hits in five innings.

"He had everything going, good curveball, spotted his fastball well, mixed in some good changeups," Royals manager Ned Yost said of Lopez. "His last four or five starts have been really really impressive."

Lopez completely handcuffed a playoff contender and lineup with three 30-homer and six 20-homer batters - turned into a disappointing night in the Bay for six innings.

"They're all impressive right now from where he has come, in my estimation, to where he's at now," Yost said of Lopez's recent outings. "He's just pitching with so much more conviction, so much more command and just throwing the ball really well."

The Royals (56-97) grabbed a 1-0 lead in the fifth against Anderson. McBroom led off the fifth with a double into the right field corner, and Cheslor Cuthbert roped a single into center field to put runners on the corners. With one out, Dini powered a 1-1 pitch deep right for a sacrifice fly as McBroom tagged up and scored.

Lopez (4-8) pitched six scoreless innings in possibly his most impressive start of the season, considering the opponent and the caliber of hitters in the lineup. He'd allowed just two hits and one walk. He also struck out four.

Tuesday night marked Lopez's third straight start having allowed two earned runs or fewer. In his last three starts, he's posted a 2.08 ERA with 17 hits, three walks and 11 strikeouts in 17 1/3 innings.

His recent run of strong starts has come after he'd struggled so much that the Royals demoted him to the bullpen mid-season.

"The last three, four starts I've been doing the same, just trusting my sinker and have that power curveball after those sinkers," Lopez said. "They swing a lot, as a team they will challenge you. You've just got to stay down in the zone and try to make them uncomfortable. At the end I was (getting) a lot of ground balls. ... They just took advantage in that last inning."

He took a 1-0 lead into the seventh, but the tide shifted suddenly. After having held the Athletics to two hits and no runs through seven innings, Lopez intended to go down and away with a fastball, but instead left it up and gave up a towering solo home run to deep center field by Matt Olson to start the seventh.

Lopez hit the next batter, Mark Canha, with the second pitch of that at-bat. Seth Brown then lined a 1-2 pitch to right-center field for an RBI double.

"It's part of the game when you (make) those kind of mistakes with those guys," Lopez said. "They are a really good lineup. I feel like I left everything I can (out there). I stuck with the plan, and I was able to execute all the pitches."

Lopez left with the Athletics leading 2-1 with no outs recorded in the seventh. Right-hander Jacob Barnes came on in relief.

The Athletics were on the verge of a huge inning with the bases loaded and one out in the inning after second baseman Whit Merrifield failed to record an out on a routine grounder as he tried unsuccessfully to cut down the lead runner going from second to third.

With the bases loaded and one out after a walk by Athletics outfielder Robbie Grossman, Barnes struck out pinch hitter Ramon Laureano and then McBroom made a sliding catch on a sinking line drive by Marcus Semien in right field to end the inning.

Both bullpens were stellar in the final two innings. Athletics closer and former Royal Liam Hendriks bounced back after having allowed the Royals rally to win in the ninth inning on Monday night. He earned his 23rd save.

The Royals and Athletics wrapped up their series on Wednesday afternoon.