U.S. District Judge S. James Otero sentenced Christopher Chaney after hearing from a tearful Johansson in a videotaped statement.
The case included the revelation that nude photos taken by Johansson of herself and meant for her then-husband Ryan Reynolds were leaked online.
"I have been truly humiliated and embarrassed," Johansson said. "I find Christopher Chaney's actions to be perverted and reprehensible."
Prosecutors said Chaney, 35, of Jacksonville, Fla., also targeted two women he knew, sending nude pictures of one former co-worker to her father. The judge noted the damage to the women was in some ways worse than what Chaney's celebrity victims endured.
The women, identified in court filings only by initials, wrote in letters to Otero that their lives have been irreparably damaged by Chaney's actions. One has anxiety and panic attacks; the other is depressed and paranoid. Both said Chaney was calculated, cruel and creepy.
"It's hard to fathom the mindset of a person who would accomplish all of this," Otero said. "These types of crimes are as pernicious and serious as physical stalking."
Prosecutors were seeking six years imprisonment, but Otero said he was concerned that Chaney would not be able to control his behavior and had shown a "callous disregard" for his actions.
Chaney, who could have faced a maximum sentence of 60 years under the law, apologized in court but denied that he had sent naked photos of women he knew to their relatives.
"I don't know what else to say other than I'm sorry," Chaney said. "I could be sentenced to never use a computer again and I wouldn't care."
Chaney previously pleaded guilty to counts that included wiretapping and unauthorized access to a computer.
Actress and singer Renee Olstead said in court Monday that she attempted to kill herself after Chaney leaked nude photos of her. She said she had never before considered suicide.
"I just really hope this doesn't happen to someone else," she said, crying. "You can lose everything because of the actions of a stranger."
Chaney looked up at her a few times as she spoke but kept his head low for most of Olstead's statement.
Chaney will be placed on three years of supervised probation when he is released and will have to notify officials of his online accounts. But the judge feared that wouldn't be enough and said he wished he could sentence Chaney to lifetime supervision.
The accounts of the cybervictims served as a cautionary tale for people - even major celebrities - who snap personal, sometimes revealing photos.
Aguilera said in a statement issued days before the sentencing that although she knows that she's often in the limelight, Chaney took from her some of the private moments she shares with friends.
"That feeling of security can never be given back and there is no compensation that can restore the feeling one has from such a large invasion of privacy," Aguilera said.
Prosecutors said Chaney illegally accessed the email accounts of more than 50 people in the entertainment industry between November 2010 and October 2011. Aguilera, Mila Kunis and Johansson agreed to have their identities made public with the hope the move would provide awareness about online intrusion.
Some of Aguilera's photos appeared online after Chaney sent an email from the account of her stylist, Simone Harouche, to Aguilera asking the singer for scantily clad photographs, prosecutors said.
Chaney was arrested in October 2011 as part of a yearlong investigation of celebrity hacking that authorities dubbed "Operation Hackerazzi." Chaney's computer hard drive contained numerous private celebrity photos and a document that compiled their extensive personal data, according to a search warrant.
He continued to pursue his victims after the FBI seized his computer, a factor Otero said warranted a harsher penalty.___
Associated Press Writer Greg Risling contributed to this report.