(Adds quotes, context)
By John Ruwitch and Fayen Wong
SHANGHAI, May 22 (Reuters) - Iranian President Hassan Rouhani said on Thursday talks over Tehran's nuclear programme had reached an important and tough juncture, but an agreement was still possible by a July deadline.
The lack of progress in talks in Vienna that ended last week between Iran and United States, Russia, China, France, Britain and Germany had raised doubts over the prospects for a breakthrough by the self-imposed July 20 deadline.
"I think the negotiations have reached a very important and sensitive and tough juncture," Rouhani told a news conference through an English interpreter. He was speaking in Shanghai where he attended a regional summit this week and held talks with Chinese President Xi Jinping.
"We cannot expect it to be resolved in just a couple of meetings, but we are not pessimistic about the final agreement. We still have time. We can achieve this. We can even do it by the deadline."
The six powers want Iran to agree to scale back uranium enrichment and other sensitive nuclear activity and accept more rigorous U.N. inspections to deny it any capability of quickly producing atomic bombs.
Tehran denies having any such underlying ambition, saying its nuclear programme is for power generation and medical purposes only.
An interim deal between Iran and the five permanent members of the U.N. Security Council plus Germany was reached in November in Geneva, aimed at persuading Iran to curb parts of its nuclear work, in return for a limited easing of sanctions.
Rouhani said an early deal would benefit all but there was "no rush" to finalise the talks. If the deadline was not met, the interim agreement could be extended for another six months, he said.
"The signs, the indications that we have been receiving in the past few days, are telling us that it is very likely that we can come to an agreement by the end of July," he said.
To reach a deal by the deadline will require good will on the part of the six countries opposite Iran at the negotiating table. In addition, "some certain countries behind the scenes who want to create problems" should not be given a chance to "sabotage" the talks, he said.
He did not specify which countries he was referring to.
After three months of mostly comparing expectations rather than negotiating compromises, the sides had intended to start drafting a final agreement in the Vienna talks that could end more than a decade of enmity and mistrust and dispel fears of a wider Middle East war.
Elected in a landslide eleven months ago, Rouhani reversed the antagonistic stance of his predecessor, Mahmoud Ahmadinejad, towards the West and led Iran into the talks about its nuclear programme.
"If we don't achieve success it means that the other side is very stubborn because my government is ready to be logical, is ready to interact with the rest of the world and cooperate with the rest of the world," he said.
"My policy is based on cooperation, not confrontation." (Reporting by John Ruwitch; Writing by Kazunori Takada; Editing by Nick Macfie)