Niemann allowed one run and two hits. He needed just 36 pitches to become the first Rays player to go four innings this spring.
Longoria doubled in a run in the first and hit a sacrifice fly in the third.
Chris Tillman pitched 2 1-3 innings for Baltimore, yielding two runs, one earned, and four hits.
Chad Moeller homered in the third but the catcher also committed two of Baltimore's five errors.
The Orioles have lost six straight.