Updated

A former shipyard worker accused of setting a fire that caused about $450 million in damage to a nuclear-powered submarine pleaded guilty Thursday under a plea agreement that could send him to federal prison for nearly 20 years.

Casey James Fury, formerly of Portsmouth, N.H., waived indictment and pleaded guilty to two counts of arson, U.S. Attorney Thomas Delahanty II said.

The 24-year-old Fury pleaded guilty to setting the fire inside the sub on May 23, as well as a second fire outside the sub on June 16 that caused little damage. The first fire carried a maximum sentence of life in federal prison, but both the defense and prosecutors agreed to recommend a sentence that ranges roughly between 15 years and 19 years.

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.

David Beneman, Fury's attorney, said he anticipated that sentencing would occur in March. He declined to discuss the plea agreement.

Delahanty planned a noon news conference to discuss details.

It took more than 100 firefighters to save the Miami in dry dock at Portsmouth Naval Shipyard in Kittery, Maine, after the fire quickly spread through forward compartments. Five people were hurt while putting out the fire.

The Navy intends to repair the Los Angeles-class attack sub, which is based in Groton, Conn., with a goal of returning it to sea in 2015.

The fire damage to the submarine, which was undergoing a 20-month overhaul, was so severe that there was speculation that the sub would have to be scrapped.

But Navy Adm. Jonathan Greenert, chief of Naval operations, said the military concluded the USS Miami can carry enough of a workload in the future to make it worth doing the repairs, which are estimated to cost about $450 million.

All weapons had been removed from the submarine during the overhaul, and there was no damage to its nuclear propulsion, located at the rear of the vessel.