The sentences were given to Ahmad Abolfathi Mohammad and Sayed Mansour Mousavi, who were arrested June 19 in Nairobi after police said they had placed the RDX explosives at the Mombasa Golf Course, Capital FM reported Thursday.
Authorities had kept them under surveillance since their arrival in the country.
Prosecutors said the men had explosives "in circumstances that indicated they were armed with the intent to commit a felony, namely, acts intended to cause grievous harm."
Chief Magistrate Waweru Kiarie said if the men had not been apprehended another incident like the 1998 bombing outside the American embassy in Nairobi that killed more than 200 people could have occurred, Kenya Broadcasting Corp. reported.
"I shudder to imagine the amount of damage that could have been seen," he said in passing the sentences.
Investigators say the men are members of Iran's Revolutionary Guards elite al-Quds force, Britain's Daily Telegraph reported. Investigators said they think the group has shipped more than 187 pounds of explosives into Kenya, the BBC reported.
Notable deaths of 2014 [PHOTOS]