"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," deputy spokesman Mark Toner said in a statement.
Toner specifically thanked Iraq's security forces, defense ministry and intelligence service for their role in securing the Americans' release.
The identities and employment of the victims was not made public.
"A force belonging to the intelligence service was able to free the three kidnapped Americans," a senior Iraqi intelligence officer told AFP, without providing details on which group had held them.
Also Read
A spokesman for the security command responsible for the capital said last month the Americans had been kidnapped from a "suspicious apartment" in Baghdad.
An Iraqi police colonel told AFP on condition of anonymity that the Americans had been brought to the apartment for "drinking and women."
Brothels and alcohol shops have been repeatedly targeted by powerful Shiite militia groups that are playing a major role in combating the Islamic State jihadist group, which has overrun large parts of Iraq.
But they and their affiliates have also been accused of abuses including summary executions, kidnappings and destruction of property.
The US is leading a coalition of countries that have bombed thousands of IS targets in Iraq and Syria and which are providing training to Baghdad's forces.
IS also has ample motive to target Americans, but while it is able to carry out bombings in Baghdad, it does not have a major presence in the city.
In December, gunmen kidnapped more than two dozen Qataris who had come to southern Iraq to hunt. Their whereabouts are still unknown, as are the identities of their kidnappers.
It had been years since an American was kidnapped in Iraq.
Issa T Salomi, an American of Iraqi origin, went missing in Baghdad in January 2010.