next Image 1 of 2

prev Image 2 of 2

Rick Perry dropped out of the presidential race Thursday and endorsed Newt Gingrich, a move that comes just two days before the South Carolina Republican primary.

The Texas governor, saying he will return to his state "with pride," announced in South Carolina that "there is no viable path forward for me in this 2012 campaign."

After surging to the front of the GOP field upon entering the race last summer, Perry struggled to sustain that support and endured disappointing finishes in the leadoff Iowa and New Hampshire contests. He said Thursday he entered the race with a "sense of calling," but realizes "when it's time to make a strategic retreat."

"I've always believed the mission is greater than the man," Perry said.

The Texas governor offered a brief but robust endorsement of former House speaker Gingrich on his way out of the race, calling him a "conservative visionary." While Perry is polling only in single digits in South Carolina, his endorsement could make a difference in the tightening contest if his supporters gravitate toward a particular candidate.

"Newt is not perfect, but who among us is? The fact is there is forgiveness for those who seek God. And I believe in the power of redemption," Perry said. "I have no question that Newt Gingrich has the heart of a conservative reformer, the ability to rally and captivate the conservative movement."

Gingrich said in a statement he is "humbled and honored" to have Perry's support.

Perry was seen as competing for social conservative supporters alongside Rick Santorum and Gingrich, though the latter two candidates were faring much better in the polls.

Gingrich has been trying to lock down support of primary voters who are reluctant to back front-runner Mitt Romney, even urging Santorum and Perry to drop out earlier in the week. Following a strong debate performance on Monday, recent polls have shown Gingrich closing the gap with Romney -- two new polls even show Gingrich narrowly leading in South Carolina.

But the race remains in flux. Santorum enjoyed a burst of good news Thursday when the Iowa GOP announced that certified vote totals showed Santorum actually led Romney by 34 votes in the Iowa caucuses. Party officials initially said Romney won that contest by eight votes. The results from eight precincts are missing, making it virtually impossible to declare an official winner, but the Iowa announcement Thursday could help Santorum build the case for his candidacy. He and Ron Paul have trailed Gingrich and Romney in most recent polls.

Gingrich also is bracing for an interview set to air Thursday night with his second ex-wife, while Romney continues to face questions about his personal wealth and tax records.

Perry is withdrawing ahead of another presidential debate Thursday night. The Texas governor has struggled at the debates -- his campaign took one of its biggest hits at a debate last year when he failed to initially recall which three federal departments he wanted to abolish. Perry plans to return to Texas after announcing his withdrawal late Thursday morning.

Perry is the second candidate this week to withdraw from the race. Former Utah Gov. Jon Huntsman earlier dropped out following a distant third finish in the New Hampshire primary. He endorsed Romney for the nomination.

Fox News' Carl Cameron contributed to this report.