Former prime minister Stephen Harper's top national security adviser is retiring from the public service after 39 years in some of the bureaucracy's most secretive top jobs.

Harper tapped Richard Fadden for the role in the wake of the Oct. 22 attack on Parliament Hill, a time of mounting extremist threat levels.

He was subsequently kept in that position for the first few months of Prime Minister Justin Trudeau's government.

"On behalf of all Canadians, I wish Dick the very best in retirement and thank him for his distinguished record of service to his country," Trudeau said Thursday in a written statement.

A noted expert on intelligence and national security said that this sort of personnel shuffling is to be expected with the arrival of a new prime minister.

"I don't think anybody is suggesting that Fadden was pushed out or anything like that," Wesley Wark, a professor at the University of Ottawa, said in an interview.

A prime minister's relationship with a national security adviser is deeply personal, Wark added, noting that a similar disposition is helpful when dealing jointly with pressing threats to the homeland.

"There always has to be a chemistry there. The Trudeau government has taken its time in deciding who they might want. They're still feeling their way in many respects in regards to national security policy, so I think it made a lot of sense [for Fadden to retire now]."

Comments on China caused controversy

Prior to joining Harper's inner circle, Fadden was the director of the Canadian Security Intelligence Service from 2009 to 2013.

Fadden courted controversy in that role when he told CBC News in 2010 that some provincial politicians had "developed quite an attachment to foreign countries."

"There are several municipal politicians in British Columbia and in at least two provinces there are ministers of the Crown who we think are under at least the general influence of a foreign government," Fadden said at the time.

He had previously named China as an aggressive recruiter in Canada.

The comments angered the Chinese community, which felt it had been unfairly singled out by Fadden's remarks, and prompted calls for Fadden's resignation.

CSIS head called to resign1:38

But his position was supported by some in the intelligence community, who said China has been trying to unduly influence government decisions.

"There is direct evidence that there is much more than just lobbying. There is evidence that CSIS has collected that B.C. officials had been compromised, sometimes with their knowledge, occasionally without their knowledge," Michel Juneau-Katsuya, a former head of Asia Pacific Affairs for CSIS, said at the time.

Wark said that these efforts to bring CSIS "out into the public domain and explain some of its concerns" would mar his legacy.

"I think it proved the case that for all the wealth of experience he had, and all the good judgment I'm sure, he was not very adept at being a good public communicator about CSIS operations and issues."

National security experience unparalleled

Harper respected Fadden because he was often "completely unfazed by anything," Wark said, and he was respected for his diplomatic skills in dealing with the country's allies.

Fadden, unlike many other public servants of his vintage, was uniquely qualified to head up the national security branches of government.

He started his career in government in 1977 during the Cold War, working in intelligence, and he was deeply involved in Canada's response to the Sept. 11 attacks in his role as the deputy clerk of the Privy Council Office, the branch of government that directly serves the prime minister.

"It's really a career marked by the amount of time and positions of authority that he held in the intelligence and security community," Wark said. "I think that's important, because in a Canadian context there has often not been a lot of deep knowledge in the senior ranks of the civil service with critical national security issues."

"Fadden stood out," Wark said, because of his longevity working in that field, which was not seen as "the most high-flying approach if you were super ambitious."