By Tabassum Zakaria

WASHINGTON (Reuters) - Republican presidential candidates showed Sunday how they plan to attack President Barack Obama's credentials as commander in chief by criticizing his actions on Iraq and Libya.

Republicans seeking their party's nomination are trying to distinguish themselves from each other and show they can take on the Democratic president in the November 2012 election.

Herman Cain, a former pizza executive running first in some opinion polls, and Michele Bachmann and Rick Perry, early rising stars whose popularity has faded, threw jabs at Obama's foreign policy Sunday television talk shows.

Cain and Perry, the governor of Texas, said Obama's decision to pull troops from Iraq by the end of the year was a mistake, despite the pact having been forged with Iraqi leaders by Republican President George W. Bush.

"For the president to announce that we are going to do a drawdown on the troops by a date certain, that just leaves a power vacuum in Iraq," Cain said on "Face the Nation" on CBS.

"It was irresponsible for George Bush to set a date certain," Cain said after being reminded of the origins of the drawdown agreement.

But he said the president must re-evaluate the situation.

"I'm not convinced that the commanders on the ground agree with that strategy," he said.

Obama, whose re-election chances depend heavily on job creation and economic recovery, has highlighted the pullout from Iraq as a sign of strong foreign policy leadership. The killings of al Qaeda leader Osama bin Laden and other senior militants are other overseas triumphs for his administration.

Cain is in a tight race with former Massachusetts Governor Mitt Romney in Iowa, which starts next year's Republican presidential nominating contests, according to a closely watched poll conducted for The Des Moines Register.

"TREMENDOUS UNCERTAINTY"

Perry, noting he had been an Air Force pilot, said Obama had a "wavering" and "aimless" approach to foreign policy.

"The idea that a commander in chief would stand up and signal to the enemy a date certain of which we're going to pull our troops out I think is irresponsible," Perry said on "Fox News Sunday."

"We need to finish our mission in Iraq and Afghanistan. You better believe I want our kids home as soon as we can and safe. But to give that signal that we're going to pull them out is really bad public policy."

Bachmann, a member of the House of Representatives, picked a fight with Obama over Libya, saying it was the "wrong decision" to involve the United States in the upheavals in the North African oil-producer.

The president has sought to portray Libya as a foreign policy success after the death of leader Muammar Gaddafi and the takeover by the opposition.

"Now we have a mess in Libya. We don't know who the ruling party will be going into Libya," Bachmann said on ABC's "This Week."

"There's tremendous uncertainty and chaos. And of course, when there's uncertainty and chaos in a nation, that's when you see trouble and potentially extremist elements that could come into power."

Bachmann said if she were president, she would focus on Iran more than Obama has.

"I wouldn't take my eye off of the fundamental problem in the Middle East today, which is an Iran seeking to gain a nuclear weapon. This will change the course of history once that occurs," she said.

"If there's anything that we have learned over the course of history, it is that when a madman speaks, we should listen. And I think in the case of Iran, that is certainly true."

(Editing by John O'Callaghan)