Ortiz also launched a pair of two-run homers, the first of which was his 400th in a Boston uniform. And he wound up with six RBIs, matching a career high.
As Ortiz exited for a pinch-runner after his double, the roars of "Papi" thundered all around him. He came out for a curtain call.
"It was good. That's when you want to see the fans enjoying what you're doing out there," said Ortiz. "The only way they can give you a standing ovation is when things are going really good."
It was the type of joyous moment that has been lacking at Fenway Park for much of this frustrating season. But through it all, Ortiz has kept hitting.
And just because the Red Sox are no longer realistic contenders for a postseason berth doesn't mean Ortiz will be taking it easy on the opposition.
"Pride," said Ortiz. "You need to have pride in what you do. You have to make sure you go out 100 percent out there and make sure you do your best. The fans come to watch you play, you've got to give them what they expect."
Ortiz joined legends Ted Williams and Carl Yastrzemski as the only players in Red Sox history to hit 400 home runs.
Hall of Famers Williams and Yastrzemski both have statues outside of venerable Fenway Park. It's easy to imagine there will be an Ortiz statue in that same general vicinity at some point.
"It's an honor to be out there mentioned with those legends, all those people who did amazing jobs and played for the Red Sox," said Ortiz. "Legendary, legendary. You come to this organization to play and you're not expecting your name to be mentioned right next to those guys. It happens. You do what you've got to do, and that's the only way to get there."
At 38, Ortiz isn't just filling out personal milestones. There are many nights when he is still putting the Red Sox on his shoulders. This was one of them.
It was a game that Boston trailed 5-1 and 6-3, but the Astros simply couldn't stop Ortiz.
"David Ortiz is a Hall of Famer," said Astros manager Bo Porter. "He's about as good as it gets in this game, but at the same time, a couple of those pitches, the location, we didn't throw the ball exactly where we were trying to throw it and a couple of them we probably should have made a better pitch than we actually made. To his credit, that's why he has the numbers he has in his career because he's paid to drive in runs."
Ortiz's second blast curled inside of Pesky's Pole in the fifth as part of the four-run rally that changed the game for the Red Sox.
"Another game of a couple home runs, six RBIs," said Red Sox manager John Farrell. "He was a main part of the offense bailing our pitching out tonight. He and [Daniel] Nava both swung the bat extremely well. Every time David comes to the plate, you think there's an opportunity or a chance we might see a ball go out of the ballpark. On two occasions tonight, that was the case."
Right after Ortiz's 401st homer with the Red Sox sliced the deficit to two runs, the Red Sox got a significant break. Yoenis Cespedes hit an infield popup so high that first baseman Jon Singleton dropped it after losing it in the lights. Cespedes roared to second, and then stole third. That was all for Houston starter Brad Peacock, as Josh Fields came on in relief. Mike Napoli worked a seven-pitch walk.
Nava hammered an RBI single to tie the game.
And Jackie Bradley Jr. belted a drive to the wall in center for a sacrifice fly that put Boston ahead at 7-6.
Rubby De La Rosa, who has been mostly effective for the Red Sox, simply didn't have it. The righty gave up nine hits, six runs and four walks over just four innings.
"It was a struggle for him tonight," said Farrell. "He struggled with his command, struggled with any type of putaway pitch."
Alex Wilson was another player who bailed out the Red Sox. The righty came on in relief of De La Rosa and notched 2 1/3 perfect innings, buying Ortiz and the offense time to get back in the game.
"Gave us a huge lift," said Farrell. "Stabilized the game, gave us a chance to have the offense get on track. The biggest thing was a zero after we scored those runs in that fifth inning."
With the Red Sox down, 5-1, in the bottom of the third, Ortiz belted his milestone homer -- a rocket, two-run blast to center.
"To be honest with you, I didn't even know I was one homer away from hitting 400 as a Red Sox," said Ortiz. "When I came back here, Tommy [McLaughlin] the clubhouse guy brought me the baseball. What I'm trying to tell you is you don't play the game for personal numbers, you play the game to do it right. Whatever you accomplish is a plus. You've got to give to the fans, what they expect even if there are some times where you don't produce, but at least they see you trying."