Gates is on a tour of the Middle East, but his stop in Iraq had not been announced beforehand.
Speaking in Israel earlier today, Gates reminded Iraqi leaders that the U.S. military commitment in Iraq is not open-ended.
He urged faster progress on political reconciliation as well as legislation on sharing oil revenues to "create an environment" in which violence could be reduced.
Gates arrived in Baghdad one day after attacks killed nearly 200 people in the worst single day of violence in the Iraqi capital since the U.S.-led security crackdown began in February.
Earlier today in Baghdad, a suicide car bomber killed at least 10 people.
(compiled from agency reports)