The 24-year-old — who was not named by the court — will serve his prison sentence in Denmark, but will then be deported to Turkey upon release, the court in Frederiksberg said in a statement.
The man, a native of Copenhagen, had been under surveillance by the intelligence services and was arrested in April 2020 immediately after purchasing a gun and ammunition.
The police had found a flag of the Islamic State group in his home.
Prosecutors had demanded a jail term of 12 years and had charged him with purchasing weapons and ammunition “with the intent of perpetrating one or more terrorist attacks”.
The potential targets were not revealed.
After the man is deported, he will be banned for life from entering Danish territory.
“I think he’s been in Turkey fewer times than many other Danish people,” his lawyer, Rolf Gregersen, told the court.
“Denmark must take responsibility for him once he was awarded Danish citizenship. They can’t just stick a postage stamp on his back and send him on his way,” the lawyer was quoted by the Danish news agency Ritzau as saying.
The Danish intelligence services, which have foiled a number of attacks in recent years, categorise the risk of an attack against Denmark as “serious”, six years after an Islamist-motivated double attack in Copenhagen left two people dead.