KABUL (Reuters/AFP) Iranian President Mahmoud Ahmadinejad and Defence Secretary Robert Gates traded barbs on Wednesday during briefly overlapping visits to Afghanistan, where Washington has troops at war but Tehran has growing clout. Ahmadinejad, who arrived as Gates was wrapping up a three-day visit, told a news conference alongside Afghan President Hamid Karzai that US and Western troops would never defeat terrorism by waging war in Afghanistan. Ahmadinejad who paid his first visit to Afghanistan since he and his Afghan counterpart Karzai were re-elected last year, took issue with the policies of arch-foe Washington. We do not see the presence of foreign military forces in Afghanistan as a solution for peace in Afghanistan, Ahmadinejad told the joint news conference. Gates said earlier in the week Iran was playing a double game in Afghanistan by being friendly to the government while trying to undermine the United States. He said on Wednesday he had passed those concerns on to Karzai. Tehran blames Western military intervention in Afghanistan for causing instability and Ahmadinejad turned Gates earlier comment around. Our policy is full support for the Afghan people and Afghan government and reconstruction of Afghanistan and we will continue this support in the future, Ahmadinejad said. Why is it that those who say they want to fight terrorism are never successful? I think it is because they are the ones who are playing a double game, Ahmadinejad said. They are the ones who set the terrorists on their course and now they say: 'Now we want to fight them. Well they cannot, it is impossible, he told the news conference. As if addressing Gates, he said: What are you even doing in this area? You are from 10,000 km over there. Your country is on the other side of the world. What are you doing here? Gates left Kabul shortly after Ahmadinejad landed. Before leaving he described the timing of the Iranian leaders visit as clearly fodder for all conspiratorialists. I told President Karzai that we want Afghanistan to have good relations with all of its neighbours. But we also want all of Afghanistans neighbours to play an upfront game dealing with the government of Afghanistan. Iran has wide and growing influence in Afghanistan, especially the west of the country where it has important economic ties. Millions of Afghans were refugees in Iran during three decades of war, and a dialect of Irans Farsi language is one of the two state languages in Afghanistan. Karzai said at the news conference with Ahmadinejad we assured our brothers in Iran that we do not want our soil to be used against our neighbours. Iran was the only major regional country to reject an invitation to an international conference on Afghanistan in London in January. Despite their suspicions, Western countries have praised Tehrans efforts in combating the drug trade. Iran has a serious heroin addiction problem, while Afghanistan produces nearly all the worlds opium used to make heroin.