Newt Gingrich has pledged that on his first day as president he will set up a constitutional showdown by ordering the military to defy a supreme court ruling extending some legal rights to foreign terrorism suspects and captured enemy combatants in US custody.

The Republican contender told a forum of anti-abortion activists ahead of South Carolina's primary election that as president he would ignore supreme court rulings he regards as legally flawed. He implied that would also extend to the 1973 decision, Roe vs Wade, legalising abortion.

"If the court makes a fundamentally wrong decision, the president can in fact ignore it," said Gingrich to cheers.

The Republican contender, who has made no secret of his disdain for the judiciary, said that as president he would expect to have repeated showdowns with the supreme court. He said the court would lose because it is the least powerful and least accountable arm of government.

Gingrich said the first confrontation would be over its historic ruling, known as the Boumediene decision, that foreign terrorism suspects held at Guantánamo Bay have the right to challenge their detention in US courts.

"I fully expect as president that there will be several occasions when we will collide. The first one, which is actually foreign policy, the Boumediene decision which extends American legal rights to enemy combatants on the battlefield is such an outrageous extension of the court in to the commander in chief's role.

"I will issue an instruction on the opening day, first day I'm sworn in, I will issue an executive order to the national security apparatus that it will not enforce Boumediene and it will regard it as null and void because it is an absurd extension of the supreme court in to the commander in chief's (authority)."

Gingrich has said before that he regards the president as above the court when the two branches have fundamentally differing views but he went further in committing himself to setting up a constitutional crisis on his first day in office.

The Republican candidate cited what he said were precedents, including Abraham Lincoln's refusal to accept the Dred Scott decision denying that former slaves were citizens.

Gingrich's interpretations have previously been met with disdain. President George W Bush's attorney general, Michael Mukasey, has said that a president selectively ignoring supreme court decisions would turn the US in to a banana republic.

At the same election forum, Rick Perry, the Texas governor, did not go so far as Gingrich but he did say that as president he would seek to pack the supreme court with judges who would overturn the ruling legalising abortion.

"When we have a president that appoints two or three more supreme court justices - that's what the next president of the United States is liable to do - those from my perspective should be individuals who are strict constructionists who look at the constitution and interpret it in a way that our founding fathers wrote it," he said. "Therefore Roe vs Wade would be overturned."

While that comment was less contentious than Gingrich's approach, Perry created his own ripple of controversy by once again speaking ill of a foreign country.

"Think about 35,000 children every day are aborted in China. That country is destined for the ash heap of history unless it changes its values," he said.