We define the triangulated category of relative singularities of a closed subscheme in a scheme. When the closed subscheme is a Cartier divisor, we consider matrix factorizations of the related section of a line bundle, and their analogues with locally free sheaves replaced by coherent ones. The appropriate exotic derived category of coherent matrix factorizations is then identified with the triangulated category of relative singularities, while the similar exotic derived category of locally free matrix factorizations is its full subcategory. The latter category is identified with the kernel of the direct image functor corresponding to the closed embedding of the zero locus and acting between the conventional (absolute) triangulated categories of singularities. Similar results are obtained for matrix factorizations of infinite rank; and two different “large” versions of the triangulated category of relative singularities, corresponding to the approaches of Orlov and Krause, are identified in the case of a Cartier divisor. A version of the Thomason-Trobaugh-Neeman localization theorem is proven for coherent matrix factorizations and disproven for locally free matrix factorizations of finite rank. Contravariant (coherent) and covariant (quasicoherent) versions of the Serre-Grothendieck duality theorems for matrix factorizations are established, and pull-backs and push-forwards of matrix factorizations are discussed at length. A number of general results about derived categories of the second kind for curved differential graded modules (CDG-modules) over quasicoherent CDG-algebras are proven on the way. Hochschild (co)homology of matrix factorization categories are discussed in an appendix. © 2015 Mathematical Sciences Publishers.