BERLIN—The head of the United Nations atomic watchdog agency left Iran late Tuesday after failing to reach a deal to allow inspectors access to a factory making equipment for Tehran’s nuclear program, diplomats said Wednesday, casting a fresh shadow over international nuclear talks set for next week.

The Wall Street Journal reported last week that the factory, in Karaj, Iran, had resumed producing key parts for centrifuges, which are used to enrich uranium, without any monitoring by the International Atomic Energy Agency. The diplomats said talks between the IAEA and Iran were continuing.