The homer quickly changed the mood at Wrigley Field from angry to giddy. The Cubs had lost seven of their previous nine games and fans had spent much of the day booing Harden and slumping hitters such as $30 million newcomer Milton Bradley.
Harden allowed five runs and six hits with four walks in 3 2-3 innings. Three of his walks came in the fourth, when he also forced in a run by hitting Jorge Cantu with a pitch to put the Cubs behind 5-1.
It appeared Graham Taylor might be the first Marlins starter in two weeks to earn a victory when he turned a 5-2 lead over to his bullpen to begin the sixth.
But Hayden Penn issued a one-out walk to Aaron Miles and gave up a single to Mike Fontenot before leaving with a sprained ankle. Badenhop (1-1) then retired Micah Hoffpauir but walked Alfonso Soriano to load the bases, setting the stage for Theriot.
The Cubs made it 8-5 in the seventh on Geovany Soto's RBI single and Fontenot's sacrifice fly.
Cantu drove in two runs, giving him 12 RBIs in his last four games, but he struck out with two on to end the eighth. Carlos Marmol struck out the side after walking the first two batters.