We compute the electric dipole moment d(n) of the neutron from a fully dynamical simulation of lattice QCD with 2+1 flavors of clover fermions and nonvanishing θ term. The latter is rotated into a pseudoscalar density in the fermionic action using the axial anomaly. To make the action real, the vacuum angle θ is taken to be purely imaginary. The physical value of dd(n) is obtained by analytic continuation. We find d(n)=-3.9(2)(9)×10(-16) θ e cm, which, when combined with the experimental limit on d(n), leads to the upper bound |θ|≲7.4×10(-11).