KANSAS CITY, Mo. -- Los Angeles Dodgers catcher A.J. Ellis was facing one of the hottest relievers in baseball with two outs and the bases loaded in a tie game Wednesday night.
Ellis wound up taking one for the team.
He was plunked on the shoulder by Royals reliever Wade Davis, who had not allowed a run since April, and was the go-ahead run in a 5-4 victory over Kansas City.
''Our guys hung in there,'' Dodgers manager Don Mattingly said. ''We got behind. We threw some runs up there. They came back and we kept playing.''
Jamey Wright (3-2) threw 2 2/3 scoreless innings in relief of Dan Haren to pick up the win.
J.P. Howell and Brandon League worked the bottom of the eighth for the Dodgers, and Brian Wilson handled the ninth in place of closer Kenley Jansen for his first save since April 12, 2012.
It wasn't easy. Danny Valencia hit a one-out single and pinch-runner Pedro Ciriaco stole second - he was initially called out but the call was overturned by replay. But Wilson got Lorenzo Cain to line out to first base, and Ciriaco was doubled off second to end the game.
''The story is more about the bullpen and the guys scratching out the last run,'' Haren said. ''Today they played great behind me.''
Davis (5-2) had not allowed a run in 22 1/3 innings spanning his last 20 outings. But after nearly escaping a jam by catching Adrian Gonzalez in a rundown between third base and home for the second out of the eighth, the reliever walked Scott Van Slyke to load the bases.
Davis then had a 1-2 count on Ellis before hitting him in the shoulder.
''That's a tough way to go down right there,'' Davis said. ''I just tried to make a perfect pitch. It just ran away from him a little bit and came up and hit him.''
Matt Kemp homered and Gonzalez and Yasiel Puig drove in a run apiece for the Dodgers, while Dee Gordon had four hits and his league-leading 40th stolen base.
Cain and Jarrod Dyson hit solo shots for the Royals.
''"They all sting a little, some a little bit worse than others, but they all sting,'' Royals manager Ned Yost said. ''We had more than one chance in the ninth inning to pick up some runs, but we just didn't capitalize on it.''
Haren gave up two homers among six hits, walked two and was pulled after throwing 92 pitches in 4 1/3 innings. The three-time All-Star had gone at least five innings while allowing four earned runs or fewer in his previous 15 starts with the Dodgers, the longest streak by any pitcher to begin his career with the club in the last 100 years.
James Shields wasn't much better, though he lasted a whole lot longer. After breezing through the first, the Royals' ace allowed four runs, seven hits and a walk in seven innings.
Shields gave away the 1-0 lead that Cain supplied with his leadoff homer when Kemp went deep in the second. Shields then allowed two more runs in the third on consecutive triples by Gordon and Puig -- Gordon scored on a balk by Shields -- and a groundout by Gonzalez.
The Royals got one back in the fourth on Mike Moustakas's RBI single, but Los Angeles restored its cushion in the fifth when Gordon singled, swiped second and scored on Puig's double.
Kansas City finally squared things in the bottom half. Dyson led off with a homer, his first in 277 at-bats, and Billy Butler's groundout was enough to score Cain from third.
But when the game came down to a battle of bullpens, the Dodgers' proved to be better.
''Wade is solid all day, every day,'' Shields said. ''We're all human, man. It's going to be tough not to give up runs all year long. He's so strong mentally and is such a bulldog out there.''
The Dodgers selected the contract of 1B Clint Robinson from Triple-A Albuquerque and designated INF Jamie Romak for assignment. ... Mattingly said 3B Juan Uribe (hamstring) could be activated Thursday. ... The Royals have Thursday off. The Dodgers open a series against St. Louis.