Baghdad , Iraq ( CNN ) -- Two Iranians detained for years in Iraq by U.S. troops have been freed and are headed home , officials at the Iranian Embassy in Baghdad told CNN on Friday . The release comes as the mothers of three imprisoned American hikers visit their incarcerated children in Iran . The mothers have been imploring the Iranian regime to release them . But Iranian officials said the release of the two in Iraq has no connection to the status of the three hikers . Hikers ' moms meet relatives of once-detained Iranians . Ahmed Barazandeh was arrested six years ago by U.S. troops in the Iraqi city of Samarra . He had been traveling from Najaf to Samarra on a religious pilgrimage and was detained after he separated from his group . The second man -- identified by officials at Iran 's Baghdad Embassy as Abdullah Maleki and by Iran 's Press TV as Ali Abdulmalek -- was arrested by U.S. troops more than two years ago because he was not carrying a passport when he entered Iraq . The U.S. military in Iraq issued a statement saying that a detainee named Ahmad Barazandeh had been transferred to Iraqi control in June 2009 and another named Ali Abdolmaleki had been transferred in October 2009 . Barazandeh was captured in March of 2004 and Abdolmaliki in November of 2007 , it said . Hassan Kazemi Qomi , Iran 's ambassador to Iraq , is quoted by Press TV as saying the abductees were arrested on `` baseless charges and ( for ) not carrying passports . '' The ambassador said both men were on a pilgrimage to Iraqi holy cities when they were seized . The Iraqi government secured their release from a prison controlled by U.S. forces within the framework of a security agreement signed between Baghdad and Washington in 2008 . The move could be significant because Iranian President Mahmoud Ahmadinejad publicly called for a swap when asked in a newspaper interview in May about the possible release of the hikers . Last week , a French woman arrested in Iran on espionage charges was released and an Iranian who had been in a French prison for 19 years was freed . But it is not known whether that was a swap .
Release comes as the mothers seek freedom for their own lives in Iran . One man had been held 7 years , the other 6 years . Both men were on a pilgrimage to Iraqi holy sites when they were seized .