PORTLAND —  The U.S. Navy will repair a nuclear submarine that suffered $400 million in damage during a May 23 fire while in dry dock at the Kittery-Portsmouth Naval Shipyard.

“I am tremendously pleased to learn the U.S. Navy has decided to repair the USS Miami following the May fire,” U.S. Senator Olympia J. Snowe said in a statement.

Prosecutors previously said Casey James Fury, 24, of Portsmouth, N.H., confessed to setting the fire on the USS Miami submarine. They say he also confessed to setting a second fire in June near the submarine.

“I remain absolutely optimistic that the extraordinary Kittery-Portsmouth Naval Shipyard workers, who operate at the highest levels of professionalism and expertise, will be given the opportunity to make any and all necessary repairs to the submarine,” Snowe said.

Fury, a painter and sand blaster, told Navy investigators that he set the fires to get out of work because he was suffering from anxiety and having problems with his ex-girlfriend.

The May blaze quickly grew out of control and the steel hull trapped the heat, causing superheated smoke and a stubborn fire that took more than 100 firefighters to extinguish.

The submarine was undergoing a 20-month overhaul at the Navy shipyard in Kittery. The fire was confined to forward compartments and did not reach the back of the submarine where the nuclear propulsion components are located.