The National Security Ministry said in a statement that the defendants belonged to a group calling itself Jamaat al-Muwahhidun. They were all arrested in 2005.
The group's leader, Ilkin Ismayilov, received the harshest sentence.
Prosecutors say Ismayilov and his subordinates were planning to undergo military training in Afghanistan, Pakistan, Iran, and Turkey with a view to carrying out armed attacks against Azerbaijani, U.S., Israeli, and Russian targets in Baku. They were also allegedly planning to kill Azerbaijani government officials.
Authorities in secular Azerbaijan have been cracking down on all forms of unofficial Islam.