Police chief Joseph Boinett said they believed the two Kenyan men had travelled to Iran several times, identifying them as Abubakar Sadiq Louw (69) and Yassin Sambai Juma. Kenyan media gave his age as 25.
"We have irrefutable evidence they were recruited into an Iranian spying ring," he told reporters in the capital Nairobi, indicating that other unidentified security agencies had helped "uproot this network".
"The mission of that ring was to mount terror attacks in this city, not only targeting Western interests but targeting our people as well."
Louw was recruited "a number of years ago" and had been instructed to "recruit other Kenyans into the network", including Juma, with the pair making "a number of trips to Iran in which they met their handlers" and where they had been "given targets and given money."
Police gave no further details about the alleged Iranian group the men were linked to.
The announcement was made a day after Pope Francis ended a three-day visit to Kenya, where security was a major concern.
Iranians are treated with particular suspicion in Kenya, which is a close ally of Israel.
In May 2013, a Kenyan court sentenced two Iranians to life in prison for terror-related charges, including possessing explosives allegedly to be used in bomb attacks.
Ahmed Mohammed (50) and Sayed Mansour (51) were found guilty of possessing 15kg of the powerful explosive RDX, which police found hidden in a hole on a golf course.
At the time, the court said they were believed to have links to a network planning bombings in Nairobi and the eastern port of Mombasa, the country's second largest city. Israeli Prime Minister Benjamin Netanyahu has accused Iran of plotting anti-Israeli attacks in Kenya.
Israeli businesses in Kenya have been targeted in the past, including the Al-Qaeda-claimed bombing of an Israeli-owned hotel in Mombasa in 2002, in which 18 people died, as well as a failed missile strike on an Israeli charter plane at the same time.