We use the duality between color and kinematics to simplify the construction of the complete four-loop four-point amplitude of N = 4 super-Yang-Mills theory, including the nonplanar contributions. The duality completely determines the amplitude's integrand in terms of just two planar graphs. The existence of a manifestly dual gauge-theory amplitude trivializes the construction of the corresponding N = 8 supergravity integrand, whose graph numerators are double copies (squares) of the N = 4 super-Yang-Mills numerators. The success of this procedure provides further nontrivial evidence that the duality and double-copy properties hold at loop level. The new form of the four-loop four-point supergravity amplitude makes manifest the same ultraviolet power counting as the corresponding N = 4 super-Yang-Mills amplitude. We determine the amplitude's ultraviolet pole in the critical dimension of D = 11/2, the same dimension as for N = 4 super-Yang-Mills theory. Strikingly, exactly the same combination of vacuum integrals (after simplification) describes the ultraviolet divergence of N = 8 supergravity as the subleading-in-1/N 2 c single-trace divergence in N = 4 super-Yang-Mills theory.