The performance of the standard CPMG sequence in inhomogeneous fields can be improved with the use of broadband excitation and refocusing pulses. Here we introduce a new class of excitation pulses, so-called axis-matching excitation pulses, that optimize the response for a given refocusing pulse. These new excitation pulses are tailored to the refocusing pulses and take their imperfections into account. Rather than generating purely transverse magnetization, these pulses are designed to generate magnetization pointing along the axis of the effective rotation of the refocusing cycle. This approach maximizes the CPMG component and minimizes the CP component of the signal. Replacing a standard 90° pulse with a new excitation pulse matched to the 180° refocusing pulse increases the signal bandwidth and improves the echo amplitudes by 30% in inhomogeneous fields in comparison to the standard CPMG sequence. Larger gains are obtained with more advanced refocusing pulses. Recent work demonstrated that it is possible to increase the signal to noise ratio (SNR) of individual echoes by more than a factor of 1.5 (in power units) without increasing the duration or amplitude of the refocusing pulses. This was achieved by replacing the standard 180° refocusing pulse by a short phase alternating pulse and the standard 90° excitation pulse by a broadband excitation pulse. We show here that with suitable axis-matching excitation pulses, the SNR further increases by over a factor of 2. We discuss the underlying theory and present several practical implementations of purely phase modulated axis-matching excitation pulses for a number of different refocusing pulses that were derived using methods of optimal control. To gain the full benefit of these new excitation pulses, it is essential to replace the standard phase cycling scheme based on 180° phase shifts by a new scheme involving phase inversion. We tested the new pulses experimentally and observe excellent agreement with the theoretical expectations. We also demonstrate that an additional benefit of axis-matching excitation pulses is the decrease of the transient that appears in the amplitudes of the first few echoes, thus enabling better measurements of short relaxation times.