Some poll workers in Boston did a double-take on Tuesday at the unusual sight of a former president of the United States campaigning inside polling places.

Bill Clinton, an inveterate campaigner who has always loved Election Day, was ranging over the state trying to pump up voters to cast their ballots for his wife, Hillary Clinton.

“We had to remind some of our poll workers that even a president can’t go inside and work a polling place,” William F. Galvin, the Massachusetts secretary of state, said in an interview.

A pool report from Mr. Clinton’s visit to Boston’s West Roxbury neighborhood on Tuesday morning said that he went inside the polling place with the city’s mayor, Martin J. Walsh. Mr. Clinton stopped at a bake sale at the entrance and then shook hands with poll workers.

When one woman asked for a photo, Mr. Clinton said, “As long as we’re not violating any election laws,” the pool report said.

One woman told him, “We’re going to get this for her.”

Another woman after meeting him said “Oh my God, thank you.”

Mr. Clinton responded, “Bless you, thank you.”

He then showed up at a library in Newton, Mr. Galvin said, and the poll workers were flummoxed.

“We had to remind everybody what the rules are, that there is no campaigning within 150 feet of the voting booths because people are entitled to their privacy,” Mr. Galvin said. “And it’s not just him but his media entourage.”

Because of the situation in Newton, Mr. Galvin said that his office called ahead to Mr. Clinton’s next stop, in New Bedford, to remind those poll workers of the rules.

“He can go in, but he can’t approach voters,” Mr. Galvin said. “We just took the extra precaution of telling them because this is not a usual occurrence. You don’t usually get a president doing this.”