Republican Robert L. Ehrlich Jr., needing to quickly gain ground in the Maryland governor's race, repeatedly lashed out at incumbent Martin O'Malley in a debate Thursday, accusing him of mishandling the state economy and supporting a group facilitating illegal immigration.

The tone was in sharp contrast to the candidates' first debate, earlier in the week, and a sign that Ehrlich is trying to change the dynamic of the race in the last weeks before the Nov. 2 election. O'Malley, a Democrat, who had a double-digit lead in a recent poll, was more measured in his comments during the exchange, hosted by The Washington Post, while pointedly saying that Ehrlich had no credibility on tax issues and had repeatedly raised taxes and fees during his term as governor.

In a wide-ranging debate - on topics that included transit options, state spending and taxes, and race and other social issues - the former Republican governor at times interrupted O'Malley, attempting to turn the governor's penchant for soaring rhetoric against him. He repeatedly accused O'Malley of evading answers to tough budget questions and "talking in cliches."

Ehrlich's energetic performance is likely to hearten his supporters, but O'Malley didn't appear to stumble, using the debate to detail his administration's accomplishments, chip away at his opponent's credibility and appeal to the Washington area's interests.

"Ehrlich couldn't afford another performance like the one he had Monday," said Todd Eberly, a political science professor at St. Mary's College of Maryland. "I think his supporters have to feel a little bit reassured and hope this is the Bob Ehrlich who shows up at future debates. . . . Is this suddenly going to change the dynamic and catapult Ehrlich into the lead? No. But it helps put him back into contention."

Keith Haller, president of Potomac Inc., an independent Bethesda-based research and consulting firm, echoed that sentiment. He said that O'Malley probably played better in the heavily Democratic Washington region but that given the different audiences that Ehrlich and O'Malley seemed to be targeting, both may be able to claim victory.

"Ehrlich's message was aimed at disaffected voters fed up with taxes and the economy," Haller said. "Those disaffecteds, by and large, are not located in the Washington suburbs of Maryland. . . . Both Ehrlich and O'Malley may have come out winners, but for different reasons."

Before an audience of nearly 300 people that included green-clad supporters of O'Malley and a section that repeatedly applauded and cheered for Ehrlich, the former governor was aggressive from the start, contending that the Democratic incumbent was not leveling with voters about the state's toughest fiscal issues.

In many ways, for Ehrlich, it was a return to core fiscal themes from early in his campaign, some of which he had not repeated in months, such as a pledge to create a bill of rights for small-business owners.

"We have lost jobs in this state. We have doubled our unemployment rate. ... Maryland has been hammered," said Ehrlich, who used the word "hammered" a half-dozen times during the hour-long, televised debate.

Those in the room saw an animated performance by Ehrlich, but people who watched the debate on television or online said that, on camera, O'Malley looked more polished and in control and that Ehrlich at times looked impatient.

Larry Hogan, a former Cabinet secretary under Ehrlich, said that the Republican base was not energized in recent days but that "they're sky high after this debate. This was the Bob Ehrlich we've been waiting for."