Updated

Germany's foreign minister held a rare meeting with Iranian President Mahmoud Ahmadinejad in Tehran in what appeared to have been a complicated deal to obtain the release of two journalists detained for four months, officials said Sunday.

Leading Iranian exile opposition representatives called Guido Westerwelle's visit a "disgrace," saying Germany was bowing to the regime and it could deal a blow to popular protests gathering new steam amid the turmoil in the Middle East.

But the foreign ministry stressed the visit's aim was solely to obtain the release of the two German journalists who had been detained in connection with a highly publicized stoning case.

"The minister's trip only served a humanitarian purpose," a foreign ministry spokesman said.

Westerwelle spoke "clearly about human rights and democracy" in his meetings with his counterpart, Ali Akbar Salehi, and Iran's president, the spokesman said. He declined to be named in line with policy.

"This is a simply a disgrace," said Kazem Moussavi, a spokesman for the Green Party of Iran in Germany. He added Westerwelle's visit came as a blow in the face of those currently taking to the streets in Iran hoping to oust Ahmadinejad.

"His meeting ignored the ruling regime's terror, the people's suffering," he said, warning the president could now use Westerwelle's visit for his propaganda.

A Paris-based spokesman for the National Council of Resistance of Iran said Westerwelle's visit at a time when the president faces popular unrest will "only embolden the regime to further suppress Iranian people."

"This trip is nothing but pinning hope on the bankrupt and utterly failed policy of appeasement and submitting to mullahs' blackmail," Shahin Gobadi said.

However, the rare top-level visit by a Western government representative in Tehran secured the release of the two German reporters.

Westerwelle described the months-long negotiations as "very complicated," but the minister was ultimately able to take the pair home on his government plane late Saturday after their 132-day-long ordeal in Iranian detention.

In a similar case, Clotilde Reiss, a young French academic, battled charges of spying in Iran for more than 10 months last year, but was eventually allowed to return to France in May after tenuous negotiations.

Two American hikers, Shane Bauer and Josh Fattal, are still detained in Iran. They were arrested while hiking in northern Iraq near the Iranian border in July 2009.

A German government official said reporter Marcus Hellwig and photographer Jens Koch had been detained under "poor conditions," and both had suffered great psychological wounds. He spoke on condition of anonymity citing the confidentiality of the information.

"I wish for both of them to quickly get over what they've experienced and find their way back to a normal life," Westerwelle told journalists in Berlin.

The reporters, working for the Berlin-based mass-circulation tabloid Bild am Sonntag, were detained in October after interviewing the son of an Iranian woman sentenced to death by stoning for adultery, Sakineh Mohammadi Ashtiani, whose case has generated widespread international outrage.

Throughout their detention in the northwestern city of Tabriz, Iranian officials accused them of a range of serious crimes and also claimed they admitted to violating Iranian laws barring those entering the country on tourist visas from working as journalists.

Ultimately, they were found guilty of committing unspecified acts against Iran's national security. But a court threw out the journalists' 20-month prison sentence Saturday, commuting it to a fine of $50,000 each and clearing the way for their release, state media reported.