The dynamics of the random-phase sine-Gordon model, which describes two-dimensional vortex-glass arrays and crystalline surfaces on disordered substrates, is investigated using the self-consistent Hartree approximation. The fluctuation-dissipation theorem is violated below the critical temperature Tc for large time tt* where t* diverges in the thermodynamic limit. While above Tc the averaged autocorrelation function diverges as Tln(t), for T<Tc it approaches a finite value q*1/(Tc-T) as q(t)=q*-c(t/t*)- (for tt*) where is a temperature-dependent exponent. On larger time scales tt* the dynamics becomes nonergodic. The static correlations behave as Tlnx for TTc and for T<Tc when x<* with *exp{A/(Tc-T)}. For scales x*, they behave as m-1Tlnx where mT/Tc near Tc, in general agreement with the variational replica-symmetry breaking approach and with recent simulations of the disordered-substrate surface. For strong coupling the transition becomes first order. © 1995 The American Physical Society.