We describe optimized coherent control methods for two-photon transitions in atoms of a ladder-type three-state energy configuration. Our approach is based on the spatial coherent control scheme, which uses counterpropagating ultrashort laser pulses to produce complex excitation patterns in an extended space. Because coherent control requires constructive interference of constituent transition pathways, applying it to an atomic transition with a specific energy configuration requires specially designed laser pulses. We show in an experimental demonstration that two-photon transition with an intermediate resonant energy state can be coherently controlled and retrieved from the resonance-induced background, when phase flipping of the laser spectrum near the resonant intermediate transition is used. A simple reason for this behavior is the fact that the transition amplitude function (added to give an overall two-photon transition) changes its sign at the intermediate resonant frequency and, thus, by proper spectral-phase programing, the excitation patterns (or the position-dependent interference of the transition given as a consequence of the spatial coherent control) can be well isolated in space along the focal region of the counterpropagating pulses.