Let Y = (Y, d) be a CAT(0) space which is either proper or of finite telescopic dimension, and gamma a countable group equipped with a symmetric and non degenerate probability measure mu. Suppose that gamma acts on Y via a homomorphism rho: gamma -> Isom(Y), where Isom(Y) denotes the isometry group of Y, and that the action given by rho has finite second moment with respect to mu. We show that if rho(gamma) does not fix a point in the boundary at infinity & part;Y of Y and the rate of escape l(rho)(gamma) = l(rho) (gamma, mu) associated to an action given by rho vanishes, then there exists a flat subspace in Y that is left invariant under the action of rho(gamma). Note that if the rate of escape does not vanish, then we know that there exists an equivariant map from the Poisson boundary of (gamma, mu) into the boundary at infinity of Y by a result of Karlsson and Margulis. The key ingredient of the proof is mu-harmonic functions on gamma and mu-harmonic maps from gamma into Y. We prove a result similar to the above for an isometric action of gamma on a locally finite-dimensional CAT(0) space.