Without a win in four Premier League away matches Arsenal feared the wait would endure when Alvaro Negredo cancelled out Sanchez’s opening goal, but Ozil struck to lift the Gunners to sixth place.
Playing in an unfamiliar 3-5-2 formation, Arsenal took the lead on 42 minutes when Sanchez curled in a free-kick following a foul on Granit Xhaka by Adam Clayton.
Boro levelled four minutes after the interval when Stewart Downing picked out Negredo.
The hosts were almost ahead when Daniel Ayala’s header was saved by Petr Cech but Ozil sealed the victory from close range after a lay-off from Aaron Ramsey.
Boro lie 19th, six points from safety.