The 27-year-old made 15 Championship appearances for Town last season, scoring three goals before joining Leeds United on loan, scoring twice in 14 outings.
Boro, who signed Carayol from Bristol Rovers for £350,000 in 2012, had loaned him to Brighton and Hove Albion during the 2014/15 season.
He was a Tony Mowbray signing who fell out of favour under Aitor Karanka after suffering a knee injury in March 2014.
Carayol played 50 games and scored 13 goals in his first two seasons on Teesside but has not featured for them in the past two campaigns.
He was told earlier in the summer he could leave and was not given a squad number for this season.
The Gambian began his career at MK Dons and has also played for Torquay United and Lincoln City.