PORTLAND, Maine - A shipyard worker who set fire to rags aboard a nuclear submarine because he wanted to go home was sentenced to a little more than 17 years in federal prison Friday for the blaze that transformed the vessel into a fiery furnace, injured seven people and caused about $450 million in damage.

Casey James Fury also was ordered to pay $400 million in restitution by a judge who weighed his lack of criminal record and the severity of the fire before imposing a 205-month prison sentence.

The 25-year-old Fury, formerly of Portsmouth, N.H., pleaded guilty to setting the May 23 fire while the USS Miami was undergoing a 20-month dry dock overhaul at Portsmouth Naval Shipyard in Kittery.

The civilian painter and sand blaster told authorities that he wanted to go home because he was suffering from an anxiety attack. He told them he never envisioned such extensive damage when he used a lighter to set fire to a plastic bag of rags that he left on a bunk in a state room.

The blaze quickly grew into an inferno spewing superheated smoke that billowed from hatches. It took 12 hours and the efforts of more than 100 firefighters to save the submarine. Seven people were hurt, the Navy has said.

Eric Hardy, a shipyard firefighter who suffered back and shoulder injuries fighting the blaze, called it the worst fire he had ever seen.

"The best way I could describe it, sir, is fighting a fire in a wood stove and climbing down a chimney," Hardy told the judge.

Fury, who had been working in the torpedo room, fled to the safety of the pier, prosecutors said, and watched as firefighters went down hatches and into the burning Los Angeles class-attack submarine, staying inside for only minutes at a time because of smoke and blistering heat.

Hardy said the smoke inside the sub was so thick he couldn't see more than a foot and his flashlight was virtually useless. Firefighters had 20-minute air packs, but it was so hard to get aboard sub and move around inside that they were limited to two to three minutes of actual firefighting.

About three weeks later, Fury set a second fire outside the crippled sub, again because of anxiety. That fire caused no damage. He pleaded guilty to two counts of arson in November.

Assistant U.S. Attorney Darcie McElwee said it was telling that Fury set a second fire after the extensive damage caused by the first one.

But the defense lawyer David Beneman contended Fury suffered from depression and anxiety and that he never intended to harm anyone. Beneman described a "spin cycle" caused by Fury's failure to receive adequate treatment.

Fury spoke briefly Friday, apologizing to the people who were hurt and saying he meant no disrespect to the Navy.

"From the bottom of my heart, I'm truly sorry for what I have done," he said. When he's release from prison, he'll have to serve five years of probation.

U.S. District Judge George J. Singal weighed the extreme damage caused by the fire against Fury's lack of criminal record, which consisted of one drunken driving arrest, in finding a sentence in the middle of the 235 months sought by prosecutors and 18 months sought by the defense. He said he was troubled that Fury set the second fire.

"One of the lessons is that a small fire can cause tremendous damage," Singal said. "Yet within a month he starts another one."

The first blaze damaged forward compartments including living quarters, a command and control center and the torpedo room. It did not reach the rear of the Groton, Conn.-based submarine, where the nuclear propulsion components are located.

Metallurgists who examined the hull found no major damage and the Navy determined it was cost-effective to repair the vessel with a goal of returning it to service in the middle of 2015. But its future is now uncertain. Repairs have been postponed under mandatory budget cuts known as sequestration.

Rear Adm. Richard Breckenridge, a submarine group commander, said the ship's extensive damage had ripple effects around the Navy, delaying repairs on other vessels and leading to longer deployments for thousands of sailors.