WASHINGTON, Oct. 4 — Senator Larry E. Craig of Idaho, defying the wishes of many in his own Republican Party, said today that he would remain in the Senate through next year despite a court ruling against him in Minnesota, where he sought to rescind his guilty plea stemming from an undercover sex sting.

Shortly after a state judge denied his request to withdraw the August plea admitting to disorderly conduct, Mr. Craig said he had reversed his previously announced decision to leave the Senate if he could not get the plea thrown out and would instead serve out his third term, which expires at the end of 2008. He said he would not run for a fourth.

“When my term has expired, I will retire and not seek re-election,” said Mr. Craig, who was accused of soliciting sex from an undercover police officer in the bathroom of the Minneapolis-St. Paul airport in early June. “I hope this provides the certainty Idaho needs and deserves.”

His decision was a major disappointment to Republican leaders, who had hoped Mr. Craig would make good on his initial pledge and spare them from the potential political liability of having a senior lawmaker who has become a national punch line.