WASHINGTON — The White House announced Friday that President Donald Trump has pardoned a Navy sailor who took photos of classified areas inside a submarine and served a year in federal prison.

White House spokeswoman Sarah Huckabee Sanders said Kristian Saucier was pardoned by Trump and the president was “appreciative” of his service to the nation. “He has been recognized by his fellow service members for his dedication skill and patriotic spirit,” Sanders said.

Trump has referenced Saucier’s case often when criticizing Democratic rival Hillary Clinton for her use of a private email server. In a January tweet, he referred to the “Deep State Justice Dept” and criticized the federal system for going after a sailor instead of a top Clinton aide.

It was Trump’s second pardon as president. He pardoned Joe Arpaio, a former six-term sheriff of metro Phoenix, in August.

Saucier’s attorney, Ronald Daigle Jr., said his client was “ecstatic. He’s so grateful that the president saw there was an injustice in this matter and he took action on it.”

Saucier pleaded guilty in 2016 to unauthorized detention of defense information for taking photos inside the USS Alexandria while it was stationed in Groton, Connecticut, in 2009.

Saucier had said previously that he had only wanted service mementos. But federal prosecutors argued he was a disgruntled sailor who had put national security at risk by taking photos showing the submarine’s propulsion system and reactor compartment and then obstructed justice by destroying a laptop and camera. Saucier claimed his prosecution was driven by sensitivity about classified information amid the scandal involving Clinton’s emails.

Saucier, of Arlington, Vermont, was a 22-year-old machinist mate on the nuclear-powered attack submarine when he took the photos. His lawyers said he knew the photos would be classified but he wanted to show his family what he did in the Navy. He denied sharing the photos with any unauthorized recipient.

After Trump won election, Daigle discussed the case at Trump Tower with Michael Flynn, the president’s former national security adviser, who encouraged a formal pardon request. Trump was later asked about the case during an interview with Fox News’ Sean Hannity and said it was “very unfair.”