Image copyright Reuters Image caption Hamid Aboutalebi is a senior political adviser to President Hassan Rouhani, and says he was only a translator for the hostage-takers, not a core member of the activist group

President Barack Obama has signed into law a measure that would bar entry to any UN ambassador whom the US says has engaged in "terrorist activity".

The law came as a response to Iran's pick of a UN envoy linked to the student militants who overran the US embassy in Tehran in 1979.

The US has already denied Hamid Aboutalebi a visa, and Mr Obama said he would treat the new law as "advisory".

Iran has lodged a formal complaint with the UN over the rejection.

The bill that Mr Obama signed into law on Friday passed both houses of Congress handily following uproar over Mr Aboutalebi's links to the students who seized the US embassy in Tehran in 1979 and held the American diplomats hostage.

Mr Aboutalebi has said that he acted merely as a translator on a couple of occasions for the hostage-takers, an account corroborated by some of the activists.

A senior political adviser to President Hassan Rouhani, he has previously served as the Iranian ambassador to Italy, Belgium and Australia.

In a statement on Friday upon signing the bill, Mr Obama said, "I share the Congress' concern that individuals who have engaged in such activity may use the cover of diplomacy to gain access to our nation."

But he said the law could effectively curtail his power under the US constitution to receive or reject ambassadors, and thus he said he would treat the law "as advisory in circumstances in which it would interfere with the exercise of this discretion".

Under the 1947 Headquarters Agreement, the US is generally required to grant visas to persons invited to the UN in New York.

Iran's deputy envoy at the UN, Hossein Dehghani, has asked Committee on Relations with the Host Country for a meeting over the decision, saying the US had violated its legal obligations under international law.

"This decision of the US government has indeed negative implications for multilateral diplomacy and will create a dangerous precedence and affect adversely the work of intergovernmental organisations and activities of their member states," he warned.