U.N. Ambassador Susan E. Rice withdrew from consideration to be secretary of state on Thursday in anticipation of a fierce confirmation battle with Republican opponents, marking the first political defeat for President Barack Obama in preparing for his second term.

Ms. Rice’s announcement that she was ending her bid for the post could reverberate across two branches of government, reshaping Mr. Obama’s cabinet selections and possibly changing the makeup of the U.S. Senate.

Mr. Obama has yet to nominate anyone to succeed Hillary Clinton, who has said she doesn’t want to stay on as the nation’s top diplomat in a second term. But officials had said Ms. Rice was the leading candidate, and Mr. Obama had defended her from detractors.