Masterson (3-6) gave up four of the hits and struck out nine over seven innings in helping the Indians snap a three-game losing streak. They were swept by Cincinnati in those three losses while being outscored 24-9.
Pittsburgh has dropped four in a row after winning four straight.
Vinnie Pestano pitched the eighth for the Indians and Chris Perez worked around a one-out single in the ninth for his 21st save.
The Pirates' biggest threat came in the fourth when they loaded the bases with two away, but Masterson struck out Jose Tabata on three pitches to end the inning.
James McDonald (5-3) took the loss, his first since May 11, even though he allowed only one run on three hits in six innings.
Members of Congress to keep receiving porn magazine
Iranian woman stops the execution of son's killer