Earthquake early warning systems must save lives. It is of great importance that networked systems of seismometers be equipped with reliable tools to make rapid determinations of earthquake magnitude in the few to tens of seconds before the damaging ground motion occurs. A new fully automated algorithm based on the discrete wavelet transform detects as well as analyzes the incoming first arrival with great accuracy and precision, estimating the final magnitude to within a single unit from the first few seconds of the P wave.