The suspect, identified only by his initials of Z.R., was a member of the "Master Italian Hackers Team" that claimed responsibility for the hacks at the time on social media.
Italian police say they tracked down the suspect after he boasted on social media about being part of the group and participating in the hacks.
"The young man turned out to be one of the leaders," said Italian State Police in a statement released on Monday.
"The investigations led to a search that ended with the seizure of computer devices whose content allowed the police to acquire important clues to charge the man," State Police said.
Investigators tracked down the suspect to the city of Salò in Italy's Brescia province.
The hacker admitted to breaching and later defacing at least eight subdomains belonging to NASA's Ames Research Center, but also websites owned by Italian television Rai, the website of Italy's Penitentiary Police, and at least 60 other Italian government sites.
The typical message left on the hacked sites looked like the image below.
This is a typical defacement message. Defacing websites was once a popular practice with low-skilled hackers at the end of the 2000s and early 2010s. The practice is not as popular anymore, mainly because sites are better protected nowadays and because hackers who engage in it are ridiculed by fellow members of the hacking and hacktivism communities.
A list of defaced sites for which the group has taken credit is available here.
At the time, members of the Master Italian Hackers Team claimed to have also stolen and leaked databases from the hacked sites, although the State Police press release does not mention anything of the sort.
Members of Italy's Postal and Communications Police started investigating the Master Italian Hackers Team and its cyber-attacks on Italian government sites in 2015. Investigators said they identified hackers suspected of being part of the group a year later, in 2016.