BAGHDAD — Iraqi Prime Minister Nouri al Maliki took advantage of Barack Obama's internationally watched visit Monday to set a two-and-a-half-year timeline for the withdrawal of U.S. forces from Iraq.

Minutes after the Democratic presidential candidate met the Iraqi leader at his private residence, Maliki's spokesman, Ali Dabbagh, announced that Iraq wants American combat troops to leave by the end of 2010, a few months later than Obama has proposed.

The timing of a withdrawal from Iraq is a key election issue in the United States, where Republican candidate John McCain has advocated an indefinite American military presence, and in Iraq, which holds provincial elections later this year.

Dabbagh said Maliki and Obama didn't discuss specific proposals during the hour-long meeting. But he said Iraq would like to have all U.S. combat troops out of the country, leaving only advisers, some quick-reaction forces and air support forces behind.

"The Iraqi government sees that the end of 2010 is an appropriate date for the withdrawal of the forces," Dabbagh said.

Obama has proposed drawing down all combat brigades within 16 months after he'd become president, or roughly the spring of 2010.

After two days in Afghanistan, the Illinois senator arrived Monday on his first visit to Iraq as a presidential candidate, and he'll travel from here to the Middle East and Europe. His "fact-finding" mission, aimed at raising his credibility on top international issues, also provided Iraqi officials with the opportunity to show the population that they're committed to a getting a drawdown date in time for provincial elections scheduled for the fall.

Obama flew over Baghdad with Gen. David Petraeus, the top American military commander here, and met with Iraq's president, the leading minority-party figure and U.S. troops.

As the security situation has improved, Iraqis increasingly are calling for the drawdown of American troops, and it probably will be a top issue in the provincial elections. Maliki has tried to balance voters’ preference for the departure of foreign forces with the Bush administration’s opposition to a timeline.

In an interview with Germany's Der Spiegel magazine this week, Maliki seemed to endorse Obama’s troop-withdrawal proposal, drawing the ire of the White House. The prime minister's office later backed away from the interview. But Monday’s statement by Maliki's spokesman suggested that he's speaking with an audience different from the White House in mind: Iraqi voters.

Dabbagh stressed that Maliki is working with the administration on the issue, not the candidate.

"Senator Obama came to listen to the views of the prime minister, and the prime minister presented his views and the views of the Iraqis concerning the presence of the foreign forces in Iraq, the stages of negotiation and what we want from the forces that are present here,” Dabbagh said.

Baghdad residents seemed unimpressed by Obama’s visit, with some telling McClatchy that Iraq was turning into a stage for political theater. Several said they saw no difference between Republican candidate John McCain and Obama.

Obama's "visit is for his private benefit, to win the election race," said Ali Ahmed Abbas, 35. "I don't expect any good from this, because we have heard from other American politicians, and we didn't see any difference in their policy towards Iraq.”

The Illinois senator began his trip in the southern port city of Basra, meeting Iraqi military leaders and their British counterparts for a "situational update," according to a British spokesman there.

Later in the day, trailed by guards and fellow lawmakers, Obama swept into a presidential palace in the Baghdad neighborhood of Jadiriyah to meet Iraqi President Jalal Talabani.

Obama sat down for dinner with Petraeus and Ryan Crocker, the U.S. envoy to Iraq.

So far, Obama has refused to answer any questions about his trip.

"We had a very constructive discussion," Obama said upon leaving the meeting at the prime minister's private residence in Baghdad's fortified Green Zone. Maliki then left for a meeting in Germany.

Accompanying Obama in a bipartisan congressional delegation to the war zones were Sens. Chuck Hagel, R-Neb., and Jack Reed, D-R.I., veterans who were highly critical of the Iraq war and could play a role in an Obama administration.

David Satterfield, senior adviser to Secretary of State Condoleezza Rice and coordinator for Iraq, joined Obama during his meeting with Maliki.

(McClatchy special correspondent Jenan Hussein and Nicholas Spangler of The Miami Herald contributed to this article from Baghdad.)