West Ham will sign defender Pablo Zabaleta on a free transfer once his Manchester City contract expires in June.