The Germany international's seventh Premier League goal of the season sealed the victory after Alvaro Negredo had cancelled out Alexis Sanchez's stunning set-piece opener.
Arsene Wenger's side slumped to a 3-0 defeat to Crystal Palace last time out, prompting the manager to experiment with a 3-5-2 system at the Riverside Stadium – with Rob Holding in a back three – in an effort to encourage a more resolute display.
Chances were scarce in a poor first half, but Sanchez swept in a fine free-kick to break the deadlock just before the break, only for Negredo to equalise five minutes into the second half.
Boro had produced a spirited performance, but Ozil finished a clever team move in the 71st minute to put the visitors back in front, and they held firm in the closing stages to claim a win that moves them back to within seven points of the top four.
The defeat leaves Boro six points from safety, with only six matches left to play, while Arsenal snapped a four-match losing streak on the road in the top flight.
3000 – Sanchez’s goal was Arsenal’s 3000th away goal in English league football, the 2nd side to reach that figure (Man U, 3226). Graceland.— OptaJoe (@OptaJoe) April 17, 2017
Boro started in lively fashion, but their momentum was rather sapped when Fabio was forced off following lengthy treatment to what appeared to be a calf injury.
Marten de Roon headed past Petr Cech and into the net from an offside position, but the home side certainly looked the most likely to break the deadlock, with the Gunners looking uncertain in their new system
The visitors at last began to put Brad Guzan's goal under pressure, with Aaron Ramsey seeing a volley blocked inside the area, but Boro's defence was doing well to keep Sanchez and Olivier Giroud quiet.
However, the Chile star added a much-needed touch of quality to the match with three minutes left of the half, flighting a sublime free-kick over the wall and into the back of Guzan's net from 20 yards out.
Boro heads were down after an encouraging half ended in disappointment, but they responded quickly after the restart.
Stewart Downing was released down the right on the break and allowed time to cut inside and clip a fine cross towards the six-yard box, where Negredo rose to prod the ball past Cech and into the net.
Cech reacted well to parry a header from Daniel Ayala as Boro sensed a second, although Guzan had to charge off his line to prevent Ozil from rounding him following Sanchez's throughball.
The Gunners were looking anxious, but they took full advantage when Boro's backline parted to allow them to regain the lead. Sanchez's cross was chested down by Ramsey and Ozil drilled right-footed past Guzan at the near post, the home defence having allowed them acres of space.
4 - Mesut Ozil has been involved in four goals in his last four Premier League games (2 goals, 2 assists). Upturn.— OptaJoe (@OptaJoe) April 17, 2017
Boro pushed for a second equaliser, but Arsenal withstood the late pressure to claim an important result in their pursuit of the Champions League places, alleviating some pressure on Wenger ahead of Sunday's FA Cup semi-final date with Manchester City at Wembley.
Key Opta stats:
- Arsenal picked up only their second win in their last nine away league games (D1 L6), though both wins came against teams currently in the relegation zone (also Swansea City).
- Alexis Sanchez has scored more away goals in the Premier League this season than any other player (13).
- Middlesbrough are winless in 15 Premier League games – their longest such run in the division.
- Only Thierry Henry (12) has scored more direct free-kick goals in the Premier League for Arsenal than Sanchez (5, level with Robin van Persie).
- Mesut Ozil has scored in two of his last three league games for Arsenal, the same number he’d scored in in his previous 16.