BAGHDAD — Three Americans who were kidnapped from a Baghdad apartment by Shiite militiamen last month were released unharmed on Tuesday after the Iraqi authorities negotiated their freedom, State Department officials confirmed. After showers, medical checkups and a meal at the American Embassy, they were quickly put on a plane out of the country.

The exact circumstances of their release were not immediately clear, including whether any money was paid or prisoners were released in exchange. Officials stressed that there had been no direct negotiations between the United States and the group that abducted the men.

Throughout their captivity, American officials leaned on the Iraqi National Intelligence Service and the Iraqi military, which in turn leaned on Moktada al-Sadr, the Shiite cleric whose militia once fought against the Americans, officials said. The abductors were not believed to be under Mr. Sadr’s control, but the cleric was able to use his contacts to mediate and win their release.

The State Department issued a statement on Tuesday saying it welcomed the news. “We sincerely appreciate the assistance provided by the government of Iraq, and its whole-of-government effort to bring about the safe release of these individuals,” the statement said.