Sub-Lt. Jeffrey Paul Delisle has been given a 20-year prison sentence for selling secrets to Russia.
But the judge presiding over the case says the Halifax navy intelligence officer will serve 18 years and five months behind bars because of time he has already served.
Provincial court Judge Patrick Curran said Friday that Delisle "coldly and rationally" offered his services to Russia, who valued his work.
"I think it's clear by virtue of the fact that the GRU made substantial payments over the years ... it clearly considered what he was doing for them to be significant," Curran said, referring to the Russian intelligence agency.
"You are going to have to make this right, sir, with a substantial period in custody."
Curran also ordered Delisle to pay a fine of nearly $111,817 - the amount of money he collected from his Russian bosses - within 20 years or face two more years in prison.
Defence lawyer Mike Taylor said his client was stunned by the sentence.
"He's still a little bit in shock," Taylor said.
"It's a significant sentence that he received and one that, quite frankly, I don't think he was really expecting."
Crown attorney Lyne Decarie said she was satisfied with Curran's ruling.
"I think he took into account the seriousness of this case," Decarie said outside court.
"Deterrence, deterrence, deterrence is of the utmost importance in these cases. ... This is not your usual, your typical type of criminality that you see every day."
Shortly after sentencing, the chief of defence staff issued a statement saying an administrative review will soon be finalized to determine what penalties Delisle should face.
"Today, the Canadian Armed Forces have entered one of the final stages in the process dealing with the odious behaviour of Sub-Lt. Jeffrey Delisle," Gen. Tom Lawson said.
"Sub-Lt. Delisle failed each and every Canadian. With that said, I want to assure Canadians that we are actively pursuing measures to improve and enhance all facets of our security procedures."
Delisle, 41, pleaded guilty last October to breach of trust and communicating information that could harm Canada's interests to a foreign entity.
The Crown sought a prison sentence of at least 20 years, while the defence asked for nine to 10 years.