The Oberwolfach problem, posed by Ringel in 1967. asks for a decomposition of K-2n(+1) into edge-disjoint copies of a given 2-factor. We show that this can be achieved for all large n. We actually prove a significantly more general result, which allows for decompositions into more general types of factors. In particular. this also resolves the Hamilton-Waterloo problem for large n.