Kim and Vu made the following conjecture (Advances in Mathematics, 2004): if dgg log n, then the random d-regular graph {mathscr {G}}(n,d) can asymptotically almost surely be “sandwiched” between {mathscr {G}}(n,p_1) and {mathscr {G}}(n,p_2) where p_1 and p_2 are both (1+o(1))d/n. They proved this conjecture for log nll dleqslant n^{1/3-o(1)}, with a defect in the sandwiching: {mathscr {G}}(n,d) contains {mathscr {G}}(n,p_1) perfectly, but is not completely contained in {mathscr {G}}(n,p_2). The embedding {mathscr {G}}(n,p_1) subseteq {mathscr {G}}(n,d) was improved by Dudek, Frieze, Ruciński and Šileikis to d=o(n). In this paper, we prove Kim–Vu’s sandwich conjecture, with perfect containment on both sides, for all d where min {d, n-d}gg n/sqrt{log n}. The sandwich theorem allows translation of many results from {mathscr {G}}(n,p) to {mathscr {G}}(n,d) such as Hamiltonicity, the chromatic number, the diameter, etc. It also allows translation of threshold functions of phase transitions from {mathscr {G}}(n,p) to bond percolation of {mathscr {G}}(n,d). In addition to sandwiching regular graphs, our results cover graphs whose degrees are asymptotically equal. The proofs rely on estimates for the probability of small subgraph appearances in a random factor of a pseudorandom graph, which is of independent interest.