Two men accused of plotting to attack a Danish newspaper that published cartoons depicting the prophet Muhammad have been found guilty in the first convictions under Norway's anti-terror laws.

The Oslo district court sentenced the alleged ringleader, Mikael Davud, to seven years in prison and his co-defendant Shawan Sadek Saeed Bujak to three and a half years. Judge Oddmund Svarteberg said the court found Davud had "planned the attack together with al-Qaida".

A third defendant, David Jakobsen, was cleared of terror charges but convicted of helping the others acquire explosives. Jakobsen, who assisted police in their investigation, was sentenced to four months.

Investigators said the plot was linked to the same al-Qaida planners behind thwarted attacks on the New York subway system and a UK shopping centre in 2009.

The three men, who were arrested in July 2010, made some admissions but pleaded innocent to terror conspiracy charges and denied any links to al-Qaida.

During the trial, Davud denied he was taking orders from al-Qaida, saying he was planning a solo attack on the Chinese embassy in Oslo. He said he wanted revenge for Beijing's oppression of Uighurs, a Muslim minority in western China.

Davud, a Norwegian citizen, also said his co-defendants had helped him to acquire bomb-making ingredients but did not know he was planning an attack.

Bujak, an Iraqi Kurd, said the paper and the cartoonist were the targets, but described the plans as "just talk".

Prosecutors had to prove the defendants worked together in a conspiracy because a single individual plotting an attack is not covered by Norway's anti-terror laws.

During the trial, prosecutors presented testimony, obtained in the US in April, from three American al-Qaida recruits who had become government witnesses.

Jakobsen, an Uzbek national who changed his name after moving to Norway, provided some of the chemicals for the bomb, but claims he did not know they were meant for explosives. He contacted police and served as an informant, but still faced charges for his involvement before that.

The men had been under surveillance for more than a year when the authorities moved to arrest them in July 2010. Norwegian investigators, who worked with their US counterparts, said the defendants were building a bomb in a basement laboratory in Oslo.