A deal has been struck for a new operator to take over a historic Middlesbrough pub that has stood derelict for years.