Karstens (2-2) has won two starts in a row to add fuel to Pittsburgh's surprisingly successful campaign.
The Pirates, whose last winning season was 20 years ago, have grabbed four victories in a row to move 10 games above .500. Houston's losing streak was extended to eight games.
This was only the sixth appearance of the year for Karstens, who missed more than two months of action. He gave up four hits, struck out eight and walked one.
Joel Hanrahan walked two in the ninth, but one of those runners was erased in a double play and he earned his 22nd save.
Bud Norris (5-6) went without support and took the loss, giving up the two runs and five hits in seven innings.
Houston was shut out for the ninth time this season and for the third time in their last seven outings.
Pregnant Mila Kunis wins 'Best Villain' at MTV Movie Awards
Pistorius testifies he didn't consciously pull trigger when he shot girlfriend