We synchronize an 8.06 GHz microwave signal from a voltage-controlled oscillator with an optical pulse train from a 77.5 MHz mode-locked Er-fiber laser using a fiber-based optical-microwave phase detector. The residual phase noise between the optical pulse train and the synchronized microwave signal is -133 dBc/Hz (-154 dBc/Hz) at 1 Hz (5 kHz) offset frequency, which results in 838 as integrated rms timing jitter [1 Hz-1 MHz]. The long-term residual phase drift is 847 as (rms) measured over 2 h, which reaches 4×10(-19) fractional frequency instability at 1800 s averaging time. This method has a potential to provide both subfemtosecond-level short-term phase noise and long-term phase stability in microwave extraction from mode-locked fiber lasers.