After winning 12 of 13 games, the Rays have lost five of six.
Tampa Bay took a 3-1 lead into the sixth, but Markakis hit a solo homer in that inning and Johnson drove a two-run shot to right in the seventh off reliever Joel Peralta (1-2).
It was Johnson's first home run of the year. He came into the game batting .122. Baltimore got a solo homer from Adam Jones in the second, his 10th home run of the season.