UNITED NATIONS - US President Barack Obama and Iranian Foreign Minister Mohammad Javad Zarif shook hands at the United Nations, an Iranian official said on Tuesday, the first handshake between a US president and a high-ranking Iranian official in over 30 years.Iran and the United States have been at loggerheads since they severed diplomatic ties shortly after the 1979 Islamic revolution. But relations have improved since July when a deal ended a standoff between Iran and the West over Tehran's nuclear ambitions.The senior Iranian official said the handshake on Monday at the United Nations headquarters in New York "was not preplanned.""It was kind of accidental and happened after (President Hassan) Rouhani's speech to the U.N. General Assembly on Monday," said the senior official on condition of anonymity."Nothing was planned at all, and it just happened in a few seconds and they greeted each other as well."Iran's Students News Agency ISNA, citing an unnamed source, said Obama and Zarif shook hands when they ran into each other at the Assembly.There has already been some increased contact between the two sides in recent years. Obama and his counterpart Rouhani, spoke by telephone in 2013 and the nuclear talks involved direct talks between Iranian and US foreign ministers.The handshake could prompt hardliners in Iran to protest and to call on Zarif to provide an explanation. The minister, who is known as a pragmatist, had to appear before parliament for taking a 15-minute walk down Geneva sidewalks with Kerry during nuclear talks in January.A landmark nuclear deal was reached between Tehran and six major global powers in July aimed at curbing the country's nuclear program in exchange for lifting economic sanctions.