PORTLAND — So a rabbi walks into a doughnut shop …

No, seriously.

Rabbi Akiva Herzfeld leads Congregation Shaarey Tphiloh, the oldest Orthodox Jewish synagogue north of Boston, at nearly 108 years.

For the past three years, shortly before Hanukkah, he would drive to Boston — actually, suburban Brookline or Newton — to buy a couple boxes of sufganiyot, as they are known in Israel.

We know them as jelly doughnuts.

Along with potato latkes, the sufganiya (if you can stop at one) is as much a part of the celebration of Hanukkah for some Jews as the lighting of the menorah.

In larger cities with ample Jewish populations, kosher bakeries make sufganiyot. Maine has no kosher bakers. But Portland does have, as a member of Herzfeld’s congregation told him last week, a bakery that still makes doughnuts by hand.

Tony’s Donuts.

“So I went over and they were very welcoming,” Herzfeld said. “They showed me all the ingredients they use in the whole shop, and everything was kosher. I asked about changing the (frying) oil and they said we could change the oil on Friday. So we did that.”

As owner Rick Fournier looked on, Herzfeld added a ceremonial drop of olive oil to the soybean-based oil that’s used to fry the doughnuts, symbolic of the ritually pure olive oil that burned for eight days after the re-dedication of the Temple in Jerusalem 2,000 years ago.

On Monday afternoon, Herzfeld returned to Tony’s Donuts to light the deep fryers, add a few more drops of olive oil and declare the doughnuts kosher according to the highest standards of Jewish law.

Call it the blessing of the sweet.

“It’s nice that they’re willing to do this,” Herzfeld said after Tim Hunnewell, a baker, showed him how to use a wooden stick to turn the doughnuts in the oil, then guided him through the process of spearing a dozen, hanging them over a large bowl and dousing them with gooey glaze from a metal pitcher.

At a party Wednesday night at Shaarey Tphiloh, guests will be tempted by a few hundred of Tony’s kosher jelly doughnuts, instead of the slightly stale – and, at eight bucks a dozen, overpriced – suburban Boston doughnuts of years past.

The party, scheduled to begin at 7 p.m., celebrates the first night of Hanukkah.

The Jewish Community Alliance of Southern Maine, in its news bulletins, is now advertising Tony’s Donuts as a kosher Hanukkah treat and has placed a big order for distribution to firefighters and police officers.

“In America, the doughnut is like the second food to the latke” in Hanukkah celebrations, Herzfeld said. “Whereas in Israel, the doughnut is more prominent than the latke.”

That may change in Maine if Tony’s Donuts – now certified as kosher – catch on.

Staring at thick circles of dough floating in the hot oil Monday afternoon put Rabbi Herzfeld in a pensive mood.

“They say the creation of the world is actually like a bagel or a doughnut,” he said, “where God’s emanation is very powerful and intense. And then God withdraws, and is able to leave a hole in the world for us.”

He smiled at a visitor’s puzzled expression and continued to explain.

“Meaning, if the whole world was sunlight, it would be too intense for us to exist. Same thing with God. He creates the world and then he withdraws … and leaves an opening. It’s actually a symbol of Jewish theology.”

And some food for thought.