Desmond Jennings and John Jaso also homered for the Rays, who started a seven- game road trip.
Shields (12-10) gave up one run on seven hits while improving to 9-5 lifetime against Toronto. He struck out 12 and walked one.
The Rays have had 11 consecutive starts of seven or more innings, the longest streak by any team since June 2003, when the Seattle Mariners had 11 straight.
Brett Lawrie hit a solo homer for the Blue Jays, who have lost five of seven.
Henderson Alvarez (0-2) allowed four runs on four hits over six innings to suffer the loss. He struck out six and walked two.
Toronto was without manager John Farrell, who has been diagnosed with pneumonia.
Meanwhile, Niemann was 1-4 after a 3-2 loss to the Blue Jays at Tampa Bay on May 4, which dropped him to 3-3 in nine career starts in the matchup.
He didn't lose again in his next 10 starts while going 7-0 and lowering his earned run average from 5.74 to 3.29.
The streak ended in his most recent outing on Aug. 22 against Detroit, when he allowed four runs on six hits in 7 1/3 innings of a 5-2 loss.
Niemann has pitched at least six innings and allowed three runs or less in eight of his last 10 starts.
Rookie southpaw Luis Perez makes his second career start for Toronto after 29 relief outings.
The 25-year-old Dominican was 2-2 with four holds and two blown saves before he was inserted into the rotation on Aug. 21 at Oakland.
He allowed a single hit in six scoreless innings of a 1-0 victory, walking two batters and striking out four while instantly trimming his ERA from 3.71 to 3.26.
Perez has never faced the Rays.