PRESIDENT OBAMA AND Mitt Romney faced off Tuesday night in a scrappy, at times downright nasty town-hall debate that featured a feistier, more focused Obama than was seen in their first encounter and that broadened the discussion to social issues such as immigration, contraceptive coverage and gun control. If the candidates’ remarks did not break new, substantive ground, the evening served to sharpen differences between them and to give each a chance to make a sales pitch to crucial constituencies, particularly to women voters. The two men tangled repeatedly over facts, from precisely how the president characterized the Libya attack to oil production on federal land.

Mr. Romney’s strategy was to describe the past four years as a failed experiment and to further cement the more moderate image he began to try out in the earlier encounter. “The president has tried, but his policies haven’t worked,” Mr. Romney said. Pivoting from some of the conservative rhetoric of the Republican primary season, Mr. Romney made the rather unconvincing argument that his push for illegal immigrants to “self-deport” was a kinder, gentler alternative to mass roundups. He implied that he was in favor of a path to legalization for the children of illegal immigrants despite the fact that, during the primary season, he opposed the major piece of such legislation, the Dream Act, and backed only a narrow path for those who serve in the military.

Mr. Obama’s approach was to paint Mr. Romney as a shape-shifting plutocrat who made President George W. Bush look squishily moderate by comparison. “George Bush didn’t propose turning Medicare into a voucher,” he said. “George Bush embraced comprehensive immigration reform. . . . George Bush never suggested that we eliminate funding for Planned Parenthood.”

Dismissing Mr. Romney’s invocation of his five-point plan, the president said the Republican nominee has “a one-point plan, and that plan is to make sure that folks at the top play by a different set of rules.” Hitting on Mr. Romney’s failure to offer details on how he would pay for cutting tax rates, Mr. Obama said that Mr. Romney, as a businessman, “wouldn’t take such a sketchy deal and neither should you, the American people, because the math doesn’t add up.” Mr. Obama has a fair point. Mr. Romney’s “pick a number” answer for how he would offset such a tax cut — say, by limiting deductions and credits to $25,000 — is hardly a serious way to make important policy.

In an exchange on Libya, Mr. Obama was effective in answering Mr. Romney’s criticism of the administration’s slowness to recognize that an attack on the U.S. Consulate in Benghazi was terrorism. The suggestion that the White House’s rhetoric was politically driven, he said, “was offensive. We don’t do that.” Mr. Romney challenged the president’s assertion that he had described the attack as a “act of terror” the day after it occurred, only to be told by moderator Candy Crowley that Mr. Obama was correct. Neither he nor Mr. Obama followed up on a question about why requests for greater embassy security in Libya had been denied by the State Department.

Next week’s foreign-policy debate will offer a chance for the two candidates to flesh out other differences on the subject. In the end, on the domestic front, the debate performance of both has been about as disappointing as their dodging on the campaign trail. Mr. Romney’s tax math is indeed suspect. Mr. Obama’s silence on the subject of entitlement reform is disappointing. But Tuesday’s town-hall debate at least offered a snapshot of the candidates’ views on a wider array of issues, and a portrait of two men who are determined, in the homestretch, to prevail.