We present measurements of the cross section and double-helicity asymmetry A_{LL} of direct-photon production in p[over →]+p[over →] collisions at sqrt[s]=510 GeV. The measurements have been performed at midrapidity (|η|<0.25) with the PHENIX detector at the Relativistic Heavy Ion Collider. At relativistic energies, direct photons are dominantly produced from the initial quark-gluon hard scattering and do not interact via the strong force at leading order. Therefore, at sqrt[s]=510 GeV, where leading-order-effects dominate, these measurements provide clean and direct access to the gluon helicity in the polarized proton in the gluon-momentum-fraction range 0.02<x<0.08, with direct sensitivity to the sign of the gluon contribution.