Sarkozy urged other European nations to follow his lead and rebuild ties with the country that was shunned diplomatically because of Europe's opposition to the U.S.-led war.
Sarkozy was received by Iraqi President Jalal Talabani and an honor guard in a televised welcome ceremony held outdoors despite gusty winds in Baghdad.
The visit - which was unannounced beforehand as is usual with visitors to Iraq for security reasons - was the first stop by the French president as part of a regional tour that was to include travel to, and .
The French leader, who also met later with Prime Minister Nouri al-Maliki, praised Iraq for successful provincial elections held last month without major violence, and he promised economic and political support for the country.
"wants to turn toward the future, the future of Iraq, which is turning the painful pages that it has been living through these past years," he said at a news conference. "For stability in the region, a united and democratic Iraq is imperative."
Sarkozy, who was accompanied by French Foreign Minister Bernard Kouchner, urged other European leaders to re-engage with Iraq.
"We want to encourage all European countries to come," he said. "It is in Europe's interest to extend a hand here and to support the peace."
Sarkozy, nicknamed "Sarko l'Americain" for his admiration and support of the United States, has been seeking to re-establish ties with Iraq and shore up relations with Washington that were deeply strained by his predecessor's opposition to the 2003 U.S. invasion.
Then-President Jacques Chirac's refusal to back the U.S.-led military effort in Iraq led to a new low in France-U.S. ties. France was vilified in U.S. public opinion. Some Americans boycotted French wines, and french fries took on the name "freedom fries" in the House of Representatives cafeteria.
Al-Maliki told reporters the French would build a new embassy in Baghdad and open two consulates in the Kurdish city of Irbil and in the southern city of Basra, the center of Iraq's southern oil industry.
The French president welcomed security gains, saying the decline in violence had paved the way for his visit, but cautioned the situation remained fragile.
"The situation is not perfect but who could have bet even a few months ago that I could come here for talks under these conditions?" he said. "Iraq represents a hope that has not yet reached fruition."
But highlighting the fragile stability, a bomb attached to a car belonging to one of the guards of Shiite Vice President Adel Abdul-Mahdi exploded near a hospital and less than half a mile away from the French Embassy in central Baghdad on Tuesday morning, wounding the guard and two bystanders, police said.
Kouchner made the first trip by a senior French official to the country in August 2007. He also traveled to Iraq in June.
But a spokeswoman from France's Elysee presidential palace confirmed that Sarkozy's visit to Iraq was the first-ever by a French president. She was speaking on condition of anonymity, in accordance with Elysee policy.
The visit comes as President Barack Obama is seeking to bolster support for the military effort in Afghanistan and considering different timeframes to pull out the 140,000 U.S. forces in Iraq.
France, a major global arms vendor, was once a key supplier of weapons to ex-Iraqi dictator Saddam Hussein. French and Iraqi officials have said talks were under way on resuming sales of military equipment, including helicopters and spare parts for weaponry that France sold Iraq back in the 1980s.
While Iraq's elections for powerful local councils were relatively peaceful, the announcement of preliminary results has been marred by allegations of cheating and concerns about a rise in ethnic tensions in northern Iraq.
A hard-line Iraqi Sunni Arab party that won nearly 50 percent of the vote in the province that includes the northern city of Mosul offered cooperation talks with Kurds.
Sunni lawmaker Osama al-Nujaifi said Tuesday that his National Hadba Gathering hoped to form an alliance with a rival Sunni party, Christians and other minorities.
He also said Hadba was ready "to start serious and intensive talks with the Kurdish list to deal with all the pending issues to pave the way for cooperation to rebuild the province."