We derive, using the pure-spinor formalism, the complete -including the fermions -fourpoint effective action of both type II superstrings to all orders in α ′ , at tree level in string loops. We find that, in the quartic-field approximation, the supergravity Lagrangian can be thought of as the tensor product, in a suitable sense, of two copies of the superYang-Mills Lagrangian in ten dimensions. The NS-NS three-form enters the supergravity Lagrangian through a modified connection with torsion. As a byproduct, we derive the complete, i.e. to all orders in the θ-expansion, closed-string vertex operator in a flat target-space background.