Lyles (2-1) allowed one run and six hits in his 50th career game. Travis Blackley and Hector Ambriz each got three outs before Jose Veras pitched a perfect ninth for his eighth save one night after the bullpen struggled in a 7-3 loss.
"They've been taxed a lot this year and called upon on numerous occasions, so every once in a while you're going to have the kind of game that we had last night," manager Bo Porter said. "But again, it speaks to the character of the men down there. They hold themselves accountable to holding a lead, and tonight they did a tremendous job. All of them."
Bud Norris pitched six shutout innings Tuesday, but the Royals scored seven times in the final three innings. Houston bounced back quite nicely to take two of three for its fourth series win this season.
Shields (2-5) struck out seven in seven innings while yielding two runs and seven hits. He has gone seven or more innings in each of his last six starts, but hasn't won since April 30 due in part to his offense providing him with just five runs combined in his last four starts.
"It's a little frustrating," manager Ned Yost said. "Especially when James Shields goes out and gives you the type of performance he gives you about every time he goes out. We just have not done a good job with run support with him at all."
Shields is confident it will turn around soon.
"These guys are great. They are grinding every day," Shields said. "We are going through a little struggle right now. Our heads are high, and we are staying positive. It is a long season. By no means are we out of it."
The right-hander, who was acquired in an offseason trade with Tampa Bay, retired his first two batters before running into trouble. Jason Castro singled before Martinez drove a 2-2 pitch into the seats in right for his fourth homer.
"We were able to get him right away, first inning which is huge and it gives Lyles a little bit of comfort as well," Martinez said. "Pitchers like that ... good guys, you've got to get them early before they settle in."
Castro tacked on an RBI single in the eighth inning against Kelvin Herrera.
Houston's Jimmy Paredes got his first start of the season at third base in place of Matt Dominguez, who sat out with tightness in his left quadriceps. Paredes has struggled in the outfield in the last few games, causing two collisions, but was solid at third.
Alcides Escobar smoked a grounder to Paredes with one out in the eighth, and he made a perfect throw to first to get him out.
"I don't know how hard he threw that ball across the diamond, but I would love to put a clock on it though," Porter said of the play. "He almost mishandled it and he got control of it and it was absolutely whistled across the diamond. He looked comfortable over there."
Lyles also got Gordon to bounce out with two runners on to end the fifth.
Castro, the catcher, was impressed with Lyles' work.
"That's the best I've seen him throw in a long time," Castro said. "He had command, didn't miss. When we were trying to go certain locations, he missed where we were trying to go. He didn't leave really anything over the plate for guys to hit and that's big when you can do that."
After their two-run first inning, the Astros had trouble stringing together hits against Shields. Martinez singled to start the fourth, but was thrown out trying to stretch it into a double. Chris Carter followed with a single, and Shields retired the next two batters to end the inning.
Gordon singled in the first inning to extend his hitting streak to 10 games.
Houston is off on Thursday. ... The Royals return home to open a four-game series with the Angels. ... Kansas City C Salvador Perez was out of the lineup for the second straight game after bruising his right hip after crashing into the railing chasing a foul ball on Monday. He said he has a gigantic bruise on his hip, but is OK and that he could have played on Tuesday. He is day to day. ... Dominguez is expected to be back in the lineup on Friday.
Copyright by STATS LLC and The Associated Press
HOUSTON - MAY 22: Jose Altuve #27 of the Houston Astros takes batting practice before playing the Kansas City...