Iran is helping train Taliban fighters within its borders, according to U.S. military and intelligence officials.

The United States has already said that the Taliban may be receiving limited training from the Iranians in Afghanistan, but the officials told CNN that training in the use of small arms was occurring within Iran.

"We've known for some time that Iran has been a source for both materiel and trained fighters for Taliban elements in Afghanistan," Army Lt. Col. Edward Sholtis said Monday. But, he said, it is unknown whether that training is occurring with the support of Tehran, or it is "simply something that is happening beyond the government's control."

"For some years, Iran has supplied arms and munitions to the Afghan Taliban," said a U.S. intelligence official. "It has also helped conduct at least small-scale weapons training for the Taliban. There's reason to believe that some of this training has occurred in Iran."

The officials who spoke with CNN did not say how many Taliban fighters have been trained in Iran, or whether the training was sanctioned at the highest levels of the Iranian government.

Iran, which has always denied supporting the Taliban, said the training allegations were false.

An Iranian official at the United Nations said these are "...absolutely baseless and wrong allegations, and strongly rejected by the Islamic Republic of Iran."

Related: Afghan-Iranian mountain trails reveal hidden weapons smuggling route

Gen. David Petraeus, the top U.S. military commander in the region, has said Iran was aiding the Taliban within Afghanistan but that its role was limited in scope.

Defense Secretary Robert Gates, who visited Afghanistan recently, agreed with Petraeus. "There is some [training], but it, to this point, I think, has been considered to be pretty low-level," he said.

A former CIA officer who did a strategic review of Afghanistan for the Obama administration last year said the Iranians have mastered improvised explosive devices - makeshift bombs hidden along roads and in ditches.

"They've been doing this in Lebanon, Iraq, and other places for decades," said Bruce Reidel, now a senior fellow at the Saban Institute for Middle East Policy. "They're among the best in the world in this kind of knowledge. And they're trying to transmit some of that knowledge over to the Afghan Taliban."

The Sunday Times newspaper in London quoted two unidentified Taliban commanders as saying they had attended three-month courses in Iran. CNN could not confirm those details.

Predominantly Shiite Iran has been a longtime enemy of the Taliban, which is made up primarily of Sunni Muslims.

But Reidel said that Iran views the Taliban as a way to counter U.S. pressure on Tehran.

"As the U.S. squeezes Iran, Iran is looking for places to squeeze America back," he said. "And where better than Obama's war next door in Afghanistan?"

Despite the lack of love for Iran's ayatollahs, the Taliban, said Reidel, are seeking help wherever they can get it, especially with Pakistan's recent arrests of top Taliban militants and U.S. drone attacks on Taliban havens.

But Iranian assistance to the Taliban has the potential to provoke military confrontation, Reidel said. If Iran starts supplying sophisticated surface-to-air missiles to the Taliban, then U.S. and NATO command of Afghan airspace could change just as the balance changed when the United States provided Mujahedeen fighters with Stingers in their fight against the Soviets in the late 1980s.