His performance in the 7-3 win was much more impressive considering he was battling a case of food poisoning and was ill in both the second and third innings.
"I felt terrible in the third inning, I thought: `I'm not going to make it,'" he said. "But you keep pushing yourself. It's the competitive side. I didn't want to come out of the game. I didn't want to tax the bullpen and I guess I wasn't dying, so I was able to pitch."
Cosart (6-5) allowed nine hits and three runs in his longest outing since May 5 for the win.
Matt Dominguez broke out of a slump with two hits, including a three-run double in Houston's big third inning to help the Astros to the victory.
Dominguez was 1 for 12 in the first three games of this homestand before singling in the second inning. The Astros led by one when he cleared the bases with his double in a five-run third inning that made it 5-1.
"He obviously had a couple days there where he wasn't seeing the ball too good," manager Bo Porter said. "I felt like he did a great job of making them get the ball up today. The base-clearing double was a huge hit at that moment of the game."
Tampa Bay starter Chris Archer (3-4) was done in by an error and a lack of control in his shortest start this season. He allowed three hits and six runs -- one earned -- with three walks in three innings.
The Astros got back on track after striking out a season-high 16 times in a 6-1 loss in the opener Friday night.
Altuve missed his second straight game after being hit on the right hand by a pitch on Thursday night.
"Marwin he has been absolutely huge for us the entire season," Porter said. "Whether it's giving Dominguez a day at third base or stepping in at shortstop and now stepping in at second base for Altuve being hit by a pitch, he's been constant."
Evan Longoria homered and drove in all of the runs for the Rays, who have lost 15 of their past 18 games.
Rookie Kevin Kiermaier doubled with one out in the first and scored on a single by Longoria to put Tampa Bay up 1-0.
Gonzalez got things going in the third with a one-out double before advancing to third on a wild pitch. Fowler reached and Gonzalez scored to tie it at 1-1 on an error by Archer with two outs when he missed the catch at first base.
Archer slipped and fell onto his stomach while trying to make that catch, and was unable to locate his pitches after that.
Dominguez followed with his double to center field, which hit on the wall just inches shy of the home run line, to make it 5-1. The play was reviewed and upheld.
Archer escaped the inning by striking out Chris Carter.
"I didn't execute pitches," Archer said. "It had nothing to do with me not making that play at first base. Yeah, I was frustrated. There's a ton of plays in a game. There were 40 pitches after that where I could have executed."
Alex Presley drew a walk to start the fourth inning and chase Archer. He was replaced by Cesar Ramos, who was greeted with a single by Gonzalez. Ramos struck out Jonathan Villar before Fowler's two-run double to center field pushed the lead to 7-1.
Desmond Jennings singled with one out in the fifth before Longoria launched his eighth home run this season into the Crawford Boxes in left field to get Tampa Bay within 7-3.