By JONATHAN MARTIN FEB. 7, 2016

MILFORD, N.H. — Bill Clinton uncorked an extended attack on SenatorBernie Sanders on Sunday, harshly criticizing Mr. Sanders and his supporters for what he described as inaccurate and “sexist” attacks onHillary Clinton.

“When you’re making a revolution you can’t be too careful with the facts,” Mr. Clinton said, deriding Mr. Sanders’s oft-mentioned call for a political revolution.

The former president, addressing a few hundred supporters at a junior high school here, portrayed his wife’s opponent for the Democratic nomination as hypocritical, “hermetically sealed” and dishonest.

He even likened an incident last year, in which Sanders staffers obtained access to Clinton campaign voter data, to stealing a car with the keys in the ignition.

Mr. Clinton discussed the race for nearly 50 minutes, and his comments took on a harder edge the longer he spoke. What began as a testimonial to Mrs. Clinton’s leadership and a statesmanlike lecture on her approach to issues evolved into an angrier recitation of grievances against Mr. Sanders and his fervent supporters.

“ ‘Anybody that doesn’t agree with me is a tool of the establishment,’ ” Mr. Clinton said, mocking what he described as the central critique of Mrs. Clinton by Mr. Sanders.

Mr. Clinton’s comments represented an escalation in the language that he and Mrs. Clinton’s campaign have used to attack Mr. Sanders, who has maintained a sizable advantage in the polls here. Mr. Clinton made headlines in 2008 for fiercely defending his wife, and leveling tough attacks on Senator Barack Obama, but he has been largely restrained so far in this campaign.

His heated remarks here reflected the frustration the Clintons felt two days before the primary in a state that has rewarded them in the past, but that appears ready to hand Mr. Sanders a decisive victory. Mr. Clinton seemed especially irritated that New Hampshire, after lifting his 1992 bid for the Democratic nomination and handing her a comeback win in 2008, would now abandon his wife.

Criticizing Mr. Sanders’s hastily presented health-care plan, which Mr. Clinton claimed the Vermont senator had already disavowed, the former president asked: “Is it good for America? I don’t think so. Is it good for New Hampshire? I don’t think so.”

He continued: “The New Hampshire I knew would not have voted for me if I had done that.”

But Mr. Clinton’s most pointed remarks may have been when he took aim at Sanders supporters who, he said, use misogynistic language in attacking Mrs. Clinton. He told the story of a female “progressive” blogger who defended Mrs. Clinton online through a pseudonym because, he said, the vitriol from Mr. Sanders’s backers was so unrelenting.

“She and other people who have gone online to defend Hillary, to explain why they supported her, have been subject to vicious trolling and attacks that are literally too profane often, not to mention sexist, to repeat.” Mr. Clinton, growing more demonstrative, added that the liberal journalist Joan Walsh had faced what he called “unbelievable personal attacks” for writing positively about Mrs. Clinton.

In a demonstration of how engrossed he is in this campaign, Mr. Clinton recited the names of the regional newspapers that are backing his wife’s campaign and, in a rarity, mentioned Mr. Sanders by name.

“Bernie took what they said was good about him and put it in his own endorsements,” said Mr. Clinton, fuming that Mr. Sanders used complimentary language from a Nashua Telegraph endorsement of Mrs. Clinton in his own campaign appeals.

Then, reflecting the fury among Clinton campaign advisers over what they see as the kinds of behavior Mr. Sanders gets away with, Mr. Clinton noted that the senator’s campaign had used the image of an American Legion officer in New Hampshire without his permission.

“If you point it out, it just shows how tied you are to the establishment,” he said.

In a response, Tad Devine, a senior adviser to Mr. Sanders, called it “disappointing that President Clinton has decided to launch these attacks” and said Mr. Sanders would continue to focus on his message against the rigged economy, campaign finance corruption and income inequality. “Obviously the race has changed in New Hampshire and elsewhere in recent days,” Mr. Devine said.

The appearance by Mr. Clinton, absent the entourage and crowds that usually surround the former president, was striking and somewhat poignant, and it felt far apart from the frenzied final campaigning happening around the state on Sunday. The junior high school’s small gym was not full, and only a handful of reporters showed up, at a time when campaign events are being flooded with dozens of national and international journalists.

But with Mrs. Clinton in Flint, Mich., and other Clinton staffers absorbed in the primary, Mr. Clinton seemed almost on his own: He was introduced by a local mayor and Larry Lucchino, the former chief executive of the Boston Red Sox.

Recalling his own, formative experience in this state, Mr. Clinton sounded wistful in reminiscing about his duels with Paul Tsongas, the Massachusetts senator who beat him here.

“When I campaigned against Paul Tsongas we actually had substantive debates,” he said with perhaps a selective memory given the intense attacks at the time over allegations of Mr. Clinton’s sexual misconduct and his avoidance of the draft.

Now, he complained, Mrs. Clinton is suffering through attacks from a would-be purist who, he said, is in reality a veteran politician hardly unfamiliar with the ways of politics. Citing Mr. Sanders’s attendance at a lobbyist-filled Democratic Party fund-raiser, Mr. Clinton expressed astonishment.

“I practically fell out of my chair when I saw it,” he said.

Turning to a vivid metaphor, Mr. Clinton suggested that Sanders staff members’ obtaining Clinton campaign voter data amounted to grand theft. Mr. Sanders apologized for the incident, but the former president dismissed that. He said that “in private they sent an email out” noting that the Democratic Party had left “the keys in the car, and all I did was drive off.”

That line won laughs, which seemed to be what Mr. Clinton was going for. “I want you to laugh,” he told the crowd. But he did not seem to be in the mood for levity.