We propose a novel method for analyzing precursory seismic data before an earthquake that treats them as a Markov process and distinguishes the background noise from real fluctuations due to an earthquake. A short time (on the order of several hours) before an earthquake the Markov time scale $t_M$ increases sharply, hence providing an alarm for an impending earthquake. To distinguish a false alarm from a reliable one, we compute a second quantity, $T_1$, based on the concept of extended self-similarity of the data. $T_1$ also changes strongly before an earthquake occurs. An alarm is accepted if {\it both} $t_M$ and $T_1$ indicate it {\it simultaneously}. Calibrating the method with the data for one region provides a tool for predicting an impending earthquake within that region. Our analysis of the data for a large number of earthquakes indicate an essentially zero rate of failure for the method.