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 charge 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.
The Naval Criminal Investigative Service said Fury, a painter and sandblaster, had confessed to setting 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 USS Miami in dry dock at Portsmouth Naval Shipyard in Kittery, Maine, after the fire quickly spread through forward compartments. Seven 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.
The fire caused heavy damage to forward compartments including living quarters, a command and control center, and the torpedo room but did not reach the back of the submarine, where the nuclear propulsion components are located. All weapons had been removed from the submarine during the overhaul.
Two crew members, three shipyard firefighters and two civilian firefighters were hurt as they fought the blaze.
Fury told the NCIS that he set the fire because he wanted to go home but his medical leave had been used up.
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.
An earlier estimate put the damage to the 22-year-old submarine at $400 million. Greenert said the Navy is confident the Miami overhaul can be completed for $450 million, plus-or-minus $50 million.