Maryland Gov. Martin O'Malley, a Democrat, turned back a challenge from Republican Robert L. Ehrlich Jr. on Tuesday, but Republicans still appeared on track to achieve their 2010 goal of retaking a majority of the nation's governorships.