Optically trapped ensembles are of crucial importance for frequency measurements and quantum memories but generally suffer from strong dephasing due to inhomogeneous density and light shifts. We demonstrate a drastic increase of the coherence time to 21 s on the magnetic field insensitive clock transition of (87)Rb by applying the recently discovered spin self-rephasing [C. Deutsch et al., Phys. Rev. Lett. 105, 020401 (2010)]. This result confirms the general nature of this new mechanism and thus shows its applicability in atom clocks and quantum memories. A systematic investigation of all relevant frequency shifts and noise contributions yields a stability of 2.4×10(-11)τ(-1/2), where τ is the integration time in seconds. Based on a set of technical improvements, the presented frequency standard is predicted to rival the stability of microwave fountain clocks in a potentially much more compact setup.