PORTLAND — The Porthole restaurant had a history of health code violations that went unchecked for more than two years before a city inspector closed the waterfront eatery on Thursday because of a serious rat infestation and other problems.

The Porthole, the Comedy Connection, and the Harbour’s Edge banquet hall — all in the same building on Custom House Wharf — were sufficiently cleaned up, reinspected and cleared to reopen on Saturday afternoon by health inspector Michele Sturgeon.

But inspection reports from 2007 to 2009 show that city inspectors found similar problems with dirty or malfunctioning equipment, holes in the ceiling and walls, peeling paint, broken or missing floor tiles and plumbing that wasn’t up to code.

The Porthole wasn’t inspected in 2010 or 2011, when the city was in the midst of moving responsibility for food service inspections from the code enforcement office, within the planning department, to the health and human services department, said city spokeswoman Nicole Clegg.

“We had significant staff reductions around that time and we weren’t really able to accomplish what we had done in the past,” Clegg said Monday.

A 2008 report called for a follow-up inspection to see if plumbing had been installed as instructed for the bar on the Porthole’s deck. The next available report, in 2009, makes no mention of the plumbing issue, but found several other problems, including improper food and utensil storage.

The city hired Sturgeon in September 2011, shortly after the state reduced the requirement for food service inspections from a yearly event to once every two years, Clegg said.

With about 800 food service establishments in Portland, Sturgeon must do about two inspections per day to keep up and hold food service providers accountable to the laws they’re expected to follow.

“We’re making a concerted effort to be more proactive and educate food service providers about their responsibilities,” Clegg said.

Sturgeon allowed the Porthole to open after the restaurant’s staff thoroughly cleaned the premises on Friday and Saturday and owner Oliver Keithly hired Command Pest Services of Gray to get rid of the rats and close any holes in the building.

“It’s an ongoing issue, especially in an older building on the waterfront,” Keithly said Monday afternoon.

Keithly also promised to hire a professional cleaning company to further sanitize walls, ceilings and structural features and to hire a certified food protection manager as required by state law within 60 days. Sturgeon scheduled a reinspection and planning meeting next Monday.

“I feel confident that the city and myself have worked together to alleviate any concerns,” Keithly said.

Keithly wouldn’t say how much money his business has lost or spent as a result of the shutdown. He said he’s more concerned that his business won’t survive the bad publicity.

Douglas Gardner, Portland’s health and human services director, said he’s confident Keithly has addressed significant code violations and will keep problems in check.

Three floor drains that flowed into the harbor were permanently blocked with cement, Gardner said, and several malfunctioning and dirty appliances were taken out of service, including an ice maker, a food mixer and a meat slicer.

Gardner admitted that he allowed Keithly to use the Porthole’s kitchen on Friday evening to prepare a boiled lobster dinner for a 40-person wedding reception that was scheduled to be held in the Harbour’s Edge banquet hall.

The kitchen had been thoroughly cleaned and the restaurant remained closed to the public, Gardner said. The meal was served aboard the Casablanca harbor tour boat, which docks beside the Porthole and is where the couple was married.

Keithly said he told the couple why the banquet hall was closed.

Gardner acknowledged that both Keithly and the city acted quickly to reopen the Porthole and get its employees back to work.

“It’s really about having a pest-control protocol in place and staying on top of it,” Gardner said. “The owner was motivated and we were motivated. We didn’t want to see anyone’s livelihood put at risk and we need to make sure the public’s health is protected.”

Michael Peaslee, technical services manager at Modern Pest Control in Brunswick, said it’s possible to adequately address a rodent infestation in a couple of days and he’s confident that a health inspector would err on the side of caution.

“Some of the things that led to the shutdown may not have been a priority before they became public,” Peaslee said. “Now, they have to act. It’s so situational, but it could be done in a couple of days with the right resources. I don’t think the health inspector would be letting that business open back up if they hadn’t taken care of things.”

Gardner showed his confidence in what Keithly’s has done so far by having lunch at the Porthole on Sunday — a chicken pesto sandwich that he said was “very good.”

The restaurant had a healthy lunch crowd Monday, with several tables filled indoors and on the deck. Patrons reported enjoying their meals, including Patti and Gary Field of Lompoc, Calif., who said their lobster rolls were the best they’d ever had and they liked the Porthole’s casual atmosphere.

They hadn’t heard about the health code violations. Neither had Lauren and Mary Connolly of Portland, who shared clam chowder, fish and chips and salad, and their two kids had chicken fingers.

“It was great,” Lauren Connolly said. And they said they saw no critters.

Enjoying the view from the Porthole’s deck was A.J. Deraspe, a former Portland resident who now lives and works in Los Angeles as a personal chef, nutritionist and food consultant. Deraspe and several friends had heard about the health code violations but were undeterred.

“It’s the Porthole,” Deraspe said. “Anything with that name, you shouldn’t expect white linen, fancy food and an elitist attitude. It’s perfect Old Port, seaside comfort food. And the bloody marys are great.”