Abstract. We present an extension of f (T ) gravity, allowing for a general coupling of the torsion scalar T with the trace of the matter energy-momentum tensor T . The resulting f (T, T ) theory is a new modified gravity, since it is different from all the existing torsion or curvature based constructions. Applied to a cosmological framework, it leads to interesting phenomenology. In particular, one can obtain a unified description of the initial inflationary phase, the subsequent non-accelerating, matter-dominated expansion, and then the transition to a late-time accelerating phase. Additionally, the effective dark energy sector can be quintessence or phantom-like, or exhibit the phantom-divide crossing during the evolution. Moreover, in the far future the universe results either to a de Sitter exponential expansion, or to eternal power-law accelerated expansions. Finally, a detailed study of the scalar perturbations at the linear level reveals that f (T, T ) cosmology can be free of ghosts and instabilities for a wide class of ansatzes and model parameters.