Edward Devenney, 30, from County Tyrone in Northern Ireland, pleaded guilty to violating the Official Secrets Act and misconduct, The Daily Telegraph reported.
"Those who serve their country loyally must know that those who don't will receive proper punishment," the judge, Mr. Justice John Saunders, said, explaining why he was handing down a long prison term.
Devenney's promising career in the Royal Navy got off track after a decade of service when he was charged with and acquitted of rape, a prosecutor said. He began drinking and in November 2011, while stationed on HMS Vigilant, a nuclear submarine then based at Portsmouth, started telephoning the Russian Embassy in London.
Soon after, two men who said they were Russian agents got in touch with him. They were actually agents for the British intelligence agency MI5.
Devenney, a communications engineer, provided classified information and photographs, saying he was doing it because he was angry at the Navy. But he was sometimes suspicious.
"Your accent sounds remarkably fake, like British intelligence," he told one of the supposed Russians.
Devenney will also be dismissed from the Navy.
His solicitor read a statement of apology after the hearing: "I am deeply sorry for the hurt and shame that I have brought on my family and loved ones."
Celebrity Couples of 2014 [PHOTOS]