This paper studies affine Deligne-Lusztig varieties Xw(b) in the affine flag variety of a quasi-split tamely ramified group. We describe the geometric structure of Xw(b) for a minimal length elementw in the conjugacy class of an extended affine Weyl group, generalizing one of the main results in [18] to the affine case. We then provide a reduction method that relates the structure of Xw(b) for arbitrary elementsw in the extended affine Weyl group to those associated with minimal length elements. Based on this reduction, we establish a connection between the dimension of affine Deligne-Lusztig varieties and the degree of the class polynomial of affine Hecke algebras. As a consequence, we prove a conjecture of Görtz, Haines, Kottwitz and Reuman in [10].2000 Mathematics Subject Classification. 14L05, 20G25.By the definition of defect, def(b) = def(τ ) = n − ℓ(c). Therefore dim Xw(b) dw(b).By combining Theorem 12.1 and Corollary 10.4, we have that Corollary 12.2. If G is simple and δ = id. Letw ∈W ′ and b ∈ G(L) be a basic element with supp(η(w)) = S and κ(w) = κ(b). Then dim Xw(b) = dw(b).Remark. The split case was first conjectured in [10, Conjecture 1.1.3]. A weaker result for some split classical groups was proved in [8].