The 23-year-old Spaniard has signed a three-and-a-half-year deal with the Championship outfit after Norwich accepted an undisclosed fee.
Ayala, a former Liverpool trainee, joined Middlesbrough on loan in October and has made 13 appearances for the club so far.
Having mustered only 10 first-team outings in an injury-hit first campaign with Norwich following his arrival from Liverpool in August 2011, Ayala was loaned to Nottingham Forest last season.
He once again struggled for fitness at the City Ground and appeared in only 14 games.
However, Ayala has been able to feature regularly for Aitor Karanka's Middlesbrough, who are seeking a return to England's top flight.
Get the best features, fun and footballing frolics straight to your inbox every week.
Thank you for signing up to Four Four Two. You will receive a verification email shortly.
There was a problem. Please refresh the page and try again.