Lyles (3-10) has struggled for most of the season while putting together a 5.70 ERA. He and three relievers, however, combined to halt Houston's latest losing streak at seven games.
The Astros won for the 40th time this season, seven fewer victories than any other team in the majors.
Lyles also pitched in at the plate, with an RBI double in the second that brought home Brandon Barnes after Barnes had singled in the first run of the game.
Tyler Greene added a solo homer in the seventh.
The loss went to Jonathon Niese (10-7), who gave up all three runs on six hits in seven innings.
Wilton Lopez worked the final 1 1/3 innings for the Astros to collect his second save of the season and the third of his four-year career.
Interpol investigating stolen passports on missing flight
Jessica Simpson shares three-way kiss with friends in photo