We present a mathematical model of calcium cycling that takes into account the spatially localized nature of release events that correspond to experimentally observed calcium sparks. This model naturally incorporates graded release by making the rate at which calcium sparks are recruited proportional to the whole cell L-type calcium current, with the total release of calcium from the sarcoplasmic reticulum (SR) being just the sum of local releases. The dynamics of calcium cycling is studied by pacing the model with a clamped action potential waveform. Experimentally observed calcium alternans are obtained at high pacing rates. The results show that the underlying mechanism for this phenomenon is a steep nonlinear dependence of the calcium released from the SR on the diastolic SR calcium concentration (SR load) and/or the diastolic calcium level in the cytosol, where the dependence on diastolic calcium is due to calcium-induced inactivation of the L-type calcium current. In addition, the results reveal that the calcium dynamics can become chaotic even though the voltage pacing is periodic. We reduce the equations of the model to a two-dimensional discrete map that relates the SR and cytosolic concentrations at one beat and the previous beat. From this map, we obtain a condition for the onset of calcium alternans in terms of the slopes of the release-versus-SR load and release-versus-diastolic-calcium curves. From an analysis of this map, we also obtain an understanding of the origin of chaotic dynamics.