Luke Sharrett for The New York Times

NORTH CHARLESTON, S.C. — Gov. Rick Perry of Texas dropped out of the Republican presidential race here on Thursday and announced his endorsement for the candidacy of Newt Gingrich, a man he called a “conservative visionary.”

In South Carolina Reporting on the candidates and voters in the Palmetto State.

“I’ve never believed that the cause of conservatism is embodied by one individual,” Mr. Perry said at a news conference here. “Our party and our conservative philosophy transcends any one individual.”

Mr. Perry, who opened his bid for the Republican presidential nomination five months ago here in South Carolina, conceded that “there is no viable path forward for me.” He urged Republicans to support Mr. Gingrich, who he conceded was not a perfect candidate, but was the best conservative alternative in the race.

“Newt is not perfect, but who among us is,” Mr. Perry said. “The fact is, there is forgiveness for those who seek God. And I believe in the power of redemption, for it is a central tenet of my Christian faith.”

Mr. Perry reached the decision on Wednesday night, his aides said, and informed Mr. Gingrich of his plans to leave the race. He was planning to fly home to Texas shortly after his announcement.

“I have no question that Newt Gingrich has the heart of a conservative reformer,” Mr. Perry said, adding that the Republican Party cannot squander its opportunity to put forward a “conservative leader who can bring about real change.”

In a brief announcement here, as Mr. Perry was surrounded by his wife and family, he did not acknowledge Mitt Romney by name. But his praise of Mr. Gingrich, along with his repeated calls for Republicans to elect a true conservative, seemed to be a direct shot at Mr. Romney.

It remains an open question what effect his endorsement of Mr. Gingrich will have on the South Carolina primary on Saturday. But with only four Republican candidates remaining in the race, conservatives are urging voters to coalesce around one alternative to Mr. Romney.

Mr. Perry had no immediate plans to campaign alongside Mr. Gingrich over the next two days, aides said. He did not take questions during his brief appearance here in North Charleston and left the stage after kissing his wife, Anita, and thanking his family.

Mr. Perry’s decision comes as Mr. Gingrich has picked up support in South Carolina during the past week of campaigning. A CNN/Time survey released Wednesday showed that Mr. Romney’s lead over Mr. Gingrich in South Carolina has been cut in half over the past two weeks. Mr. Gingrich has urged his other rivals to drop out so that conservative voters can coalesce around him as the alternative to Mr. Romney.

Rick Santorum, who had 16 percent support in the CNN/Time survey, on Wednesday dismissed that suggestion out of hand. Mr. Santorum is scheduled to hold two events Thursday before participating in a debate sponsored by CNN.

The decision by Mr. Perry, which was first reported by CNN, narrows the Republican field to four candidates. A new NBC News/Marist poll of likely Republican voters in South Carolina shows that among Mr. Perry’s supporters, 34 percent said Mr. Gingrich was their second choice, 20 percent said Ron Paul, 19 percent said Mr. Santorum, and 18 percent said Mr. Romney. But it is important to remember, that only 4 percent of all South Carolina likely voters said they were supporting Rick Perry to begin with.

In a statement, Mr. Romney praised Mr. Perry, who had recently called Mr. Romney, a former Massachusetts governor, “a vulture capitalist.”

“Rick Perry ran a campaign based upon love of country and conservative principles,” Mr. Romney said in a statement. “He has earned a place of prominence as a leader in our party, and I salute him for his commitment to making President Obama a one-term president and finally getting our nation’s economy back on the right track. The nation owes Governor Perry a debt of gratitude for his years of service to his state and country. I wish Anita and him well.”

It was the second time that Mr. Perry had signaled that he would leave the race. After a poor showing in the Iowa caucuses two weeks ago, Mr. Perry said that he was returning to Texas to reassess his campaign, but he decided to press ahead in South Carolina.

Mr. Perry was in the single digits in recent polls here, but his withdrawal from the race could affect the outcome of the primary by giving conservative voters one less alternative. He had been appealing heavily to South Carolina’s evangelical voters.

In an interview with reporters on Tuesday, Mr. Perry said that he would leave the decision over whether he would remain in the race to the voters of South Carolina. But in the end, a supporter said, he wanted to avoid a last-place finish in South Carolina.

Mr. Perry had entered the race on Aug. 13 amid soaring expectations that his longtime experience as a conservative Southern governor might sweep him to the nomination.

Speaking to a group of conservatives in South Carolina even as Representative Michele Bachmann was winning the Iowa straw poll, he declared his bid for the presidency by vowing to bring jobs and a conservative outlook back to the country.

“It’s time to get America working again,” he said at the time. “America is not broken, Washington is broken”.

After announcing in South Carolina that he was running for president, Mr. Perry jumped to the top of the polls, stepping on Mrs. Bachmann’s victory and presenting himself as the conservative alternative to Mitt Romney.

But after his successful entrance into the race, Mr. Perry quickly stumbled, particularly during debates.

In early faceoffs, Mr. Perry struggled to defend his past statements about Social Security, which he had called a “Ponzi scheme.” And he stumbled in answers about his support in Texas for a program that benefits illegal immigrants who want to attend the state’s colleges.

Mrs. Bachmann and his other rivals also challenged him on his decision to require young girls to be vaccinated against HPV, a sexually transmitted disease.

But the worst moment in his campaign came in a later debate, when he struggled to remember the names of three federal agencies that he would eliminate if he were elected president. As he began to explain, he could think of only two.

“Commerce, Education,” Mr. Perry said before pausing for an uncomfortable moment as he looked from side to side, counting on his fingers and flipping through his notes. As his rivals volunteered suggestions, a moderator asked Mr. Perry if he could name the third agency.

“The third one, I can’t,” he finally said, a sad look on his face, after 53 seconds had gone by. “Sorry. Oops.”

Mr. Perry’s early lead and the high expectations helped him raise more than $17 million in the first two months of the race. But his stumbles led to steadily declining poll numbers nationally and in the early voting states.

His disappointing fifth place finish in the Iowa caucuses initially led him to announce that he was suspending his campaign and heading back to Texas to “reassess” his prospects.

But Mr. Perry tweeted a picture of himself jogging the next morning, announcing that he would skip New Hampshire’s primary and head directly to South Carolina, where he hoped to do better with the state’s religious, conservative voters.

But polls in the state showed Mr. Perry lagging far behind his rivals in the race. A CNN/Time poll released on Wednesday showed him barely registering with just 6 percent support.