In this paper we have developed a model which analyzes price competition in the deregulated Spanish electricity market. This model is the first to take explicitly into account the mechanism designed in the recent Spanish Electricity Law for settling stranded costs payments. We show that stranded costs recovery and efficient competition are not necessarily incompatible. The settlement mechanism for stranded costs currently prevailing in Spain leads unambiguously to lower prices; it actually acts as a countervailing force to market power and high prices in these market. Whether equilibrium prices are higher or lower than marginal cost depends both on the distribution of total stranded cost payments among industry participants and on the exact rules used to define the entitlements.