DOHA (Reuters) - Two Saudi men who blew themselves up during a gunbattle with security forces in Jeddah last week had ties with Islamic State and were linked to past attacks on mosques and security forces in Saudi Arabia, the interior ministry said on Tuesday.

After Saturday's security operation in Jeddah's eastern Al-Harazat district, the interior ministry accused the two men of planning attacks inside the country.

A ministry statement carried by Saudi state news agency SPA on Tuesday identified one of the men as Khaled al-Serwani and said he was linked to an attack in 2015 that killed a worshipper at a Shi'ite mosque in Najan in southern Saudi Arabia.

Serwani had been "wanted in connection with numerous roles and engagements in terrorist incidents and was involved in espousing propaganda on the Internet and inciting people to fight in foreign conflict zones," said the statement.

The ministry named the second man as Nadi al-Medhiani. It said he served time in prison after fighting abroad and that he had ties to a militant suspected of involvement in attacks claimed by Islamic State.

The ultra-hardline Sunni militant group has carried out a series of bombings and shootings in Saudi Arabia since mid-2014 that have killed scores of people, mostly members of the Shi'ite Muslim minority and security services.

The militant group, bitterly opposed to Gulf Arab rulers, is trying to stir sectarian confrontation on the Arabian peninsula to bring about the overthrow of the states' ruling dynasties.

(Reporting by Tom Finn; editing by Richard Lough)