Kim and Vu made the following conjecture (Advances in Mathematics, 2004): if d >> log n, then the random dregular graph G(n, d) can asymptotically almost surely be "sandwiched" between G(n, p(1)) and G(n, p(2)) where p(1) and p(2) are both (1 + o(1))d/n. They proved this conjecture for log n << d << n(l/3-o (1)), with a defect in the sandwiching: G(n, d) contains G(n, p(1)) perfectly, but is not completely contained in G (n, p(2)). Recently, the embedding G(n, p(1)) subset of G(n, d) was improved by Dudek, Frieze, Rucinski and Sileikis to d = o(n). In this paper, we prove Kim Vu's sandwich conjecture, with perfect containment on both sides, for all d >= n/root log n. For d = O(n/root log n), we prove a weaker version of the sandwich conjecture with p(2) approximately equal to (d/n) log n, without any defect. In addition to sandwiching regular graphs, our results cover graphs whose degrees are asymptotically equal. The proofs rely on estimates for the probability that a random factor of a pseudorandom graph contains a given edge, which is of independent interest. As applications, we obtain new results on the properties of random graphs with given near-regular degree sequences, including Hamiltonicity and universality in subgraph containment. We also determine several graph parameters in these random graphs, such as the chromatic number, small subgraph counts, the diameter, and the independence number. We are also able to characterise many phase transitions in edge percolation on these random graphs, such as the threshold for the appearance of a giant component.