LOS CABOS, Mexico — President Barack Obama's nominee for ambassador to Iraq has withdrawn from the running, a US official said Monday, following claims of impropriety and opposition from Republicans.

National Security Council spokesman Tommy Vietor said the White House regretted seeing Brett McGurk "withdraw his candidacy" but praised him as a "skilled diplomat" who had served tirelessly during two administrations.

Six Republican senators had urged Obama to pull McGurk's name, saying he lacked sufficient managerial experience and also raised questions about his judgment following the publication of racy emails he sent to a reporter.

The emails dated from 2008, and some were of a sexual nature, apparently between McGurk, who was then married and serving the Bush administration in Iraq, and Wall Street Journal correspondent Gina Chon.

Chon, who is now married to McGurk, resigned from the newspaper last week.

The Republican senators said the allegations of impropriety could shred McGurk's credibility, and insisted the racy emails would undermine his ability to work in Iraq.

In a letter to Obama and US Secretary of State Hillary Clinton obtained by the New York Times, McGurk said he was withdrawing his nomination with a "heavy heart" but that the move was in "the best interests of the country."

"Iraq urgently needs an ambassador. The country is in the midst of a political crisis and our mission is undergoing rapid transformation," McGurk wrote, adding that "nothing should be allowed to distract from the pressing work that must be done to build a better future there."

He said he had come to his decision during a visit to the Arlington military cemetery with Chon on Saturday where many of those killed in Iraq and Afghanistan are now buried. Both of them had lost friends in Iraq, he said.

The hardest thing in recent weeks "was watching my wife become part of it. She is the most precious thing in the world to me and the depiction of our relationship has been both surreal and devastating," McGurk added.

News that McGurk had withdrawn from the bid to replace US Ambassador James Jeffrey came a day before the Senate Foreign Relations Committee had been due to vote on his nomination.

The White House had stood by McGurk as recently as Sunday, despite calls by political opponents on Capitol Hill for the president to name a new nominee to run America's largest foreign embassy.

Vietor said McGurk had always shown "his commitment to the national interest" and had been "willing to take on some of the toughest challenges at the toughest times in a difficult region."

"While we regret to see Brett withdraw his candidacy there is no doubt that he will be called on again to serve the country," Vietor added in a statement.

McGurk reportedly helped work on negotiations with Iraqis in 2008 over a potential deal which would have left a small US military presence in Iraq.

But that deal fell through, and Obama ordered all US forces to withdraw from Iraq last year.

News of McGurk's withdrawal surfaced while Obama was in Mexico for the G20 summit.

McGurk would have been the first US ambassador since the withdrawal of US forces. He has served in a variety of roles in Iraq and is now an adviser to Jeffrey, also an appointee of Obama.