The protesters, many of whom were from the hardline group, Hizbut Tharir, were kept well away from the mission, which is ringed by two concrete walls and barbed wire.
About 2000 police stood watch, and two water cannons were ready in case the rally turned violent.
The protesters chanted "Out of Iraq" and "Bush is a terrorist" as they gathered for hours outside the US mission in the capital Jakarta.
Anti-American sentiment in Indonesia - the world's largest Muslim nation - rose sharply after the 2001 and 2003 invasions of Afghanistan and Iraq, and anger at the United States flared again after the publication of Prophet Muhammad cartoons mostly in European newspapers.
Hundreds of people turned out for protests last month, some attacking the US Embassy with sticks and rocks.
But Sunday's rally - organised by Hizbut Tharir, which has campaigned for an Islamic state in Indonesia since the 1920s - was peaceful. Of the 5000 people who turned out, about half were women and children.
US embassy spokesman Max Kwak thanked the Indonesian police for helping to maintain order and said he respected the right of Indonesians to freedom of speech and assembly, "two of the pillars of democracy."
In addition to signs that said "Bush is Evil", protesters carried placards condemning Israel and a US mining company, which is accused of large-scale environmental damage at the site of its biggest mine in Papua province.
The focus though was on Iraq and Afghanistan.
Protester Muhammad Ismail Yusanto told the gathering: "This is an example of real colonialism; there is no other reason for them to be (in Iraq)." He demanded that the West "stop the propaganda campaign against Islam in the guise of the war on terrorism."
Last week, the US mission issued a warning to all Americans to maintain a low profile and to "exercise caution if caught in the vicinity of any demonstrations."
Indonesia is a moderate Islamic country with significant Christian, Hindu and Buddhist minorities. It has a long tradition of secularism, and is seen by Washington as a close ally in the war on terror.
The two nations have had close ties since the mid-1960s when a pro-US military dictatorship seized power in Jakarta. It was then replaced by a democratic government in 1999.