BAKU - Four foreign-trained Islamists were sentenced to up to 14 years in jail in Azerbaijan on Monday for plotting "terrorist attacks" on the eve of this year's Eurovision song contest in Baku, the latest crackdown on militancy in the oil-rich state.After 70 years of Soviet-rule, most Azeris have a relaxed attitude towards religion, but Azerbaijan, a NATO ally bordering Iran on the Caspian Sea, says it is combating increasing Islamist extremism with ties to Tehran.A court official who declined to be named told Reuters the four were sentenced to between 12 and 14 years in jail for crimes including treason, plotting terrorist attacks, arms smuggling and having links with Iran's Revolutionary Guards.Security forces killed the group's alleged leader in an operation in April and the other members of the group were arrested a month before Baku hosted Eurovision in May.The Security Ministry said those arrested had been trained in Iran, Syria, Pakistan, and some had fought NATO troops in Afghanistan. As is usual in Azerbaijan, the court proceedings were closed to the public.Last year, Azerbaijan jailed 17 members of another group it said was linked to al-Qaida, sentencing them to between five years and life in jail.Earlier this year, security forces arrested several Azeris and Iranians on suspicion of spying for Iran, plotting to attack Western targets and smuggling arms from Iran into Azerbaijan.Most of Azerbaijan's 9 million people are Shi'ite Muslims, like the vast majority of Iranians. Some 15 percent of the roughly 78-million population of Iran are also ethnic Azeris.But the government of the Republic of Azerbaijan under President Ilham Aliyev is strictly secular. Western governments and human rights groups accuse Aliyev, who succeeded his father in 2003, of rigging elections and of clamping down on dissent.Iran and Azerbaijan became embroiled in a diplomatic spat ahead of the Eurovision finals which were condemned by Iranian clerics and lawmakers who referred to a "gay parade".Iran was angered by subsequent anti-Iranian protests in Baku, where demonstrators carried pictures of President Mahmoud Ahmadinejad and Supreme Leader Ayatollah Ali Khamenei and banners that read "Azerbaijan does not need clerics-homosexuals!".Sandwiched between Iran, Russia and Turkey, Azerbaijan sells oil and gas to the West from reserves in the Caspian Sea.