We recently introduced the concept of ``k-essence'' as a dynamical solution for explaining naturally why the universe has entered an epoch of accelerated expansion at a late stage of its evolution. The solution avoids fine-tuning of parameters and anthropic arguments. Instead, k-essence is based on the idea of a dynamical attractor solution which causes it to act as a cosmological constant only at the onset of matter domination. Consequently, k-essence overtakes the matter density and induces cosmic acceleration at about the present epoch. In this paper, we present the basic theory of k-essence and dynamical attractors based on evolving scalar fields with nonlinear kinetic energy terms in the action. We present guidelines for constructing concrete examples and show that there are two classes of solutions, one in which cosmic acceleration continues forever and one in which the acceleration has finite duration.