Rep. Richard B. Nugent (R-Fla.), a lawmaker whose three sons have served in the military, made the case of captive soldier Bowe Bergdahl a personal cause. Nugent delivered speeches about Bergdahl on the House floor. He introduced two resolutions affirming that the United States would not abandon him in Afghanistan.

What Nugent wanted, he told a crowd at a rally for Bergdahl in February, was for “the United States to do everything possible not to leave any members of the armed forces behind.”

But now, Nugent says that — when he said “do everything possible” — he did not actually mean everything. Now that Bergdahl is free, the Florida Republican has become a critic of the deal that freed him.

Nugent believes that the Obama administration gave away too much by sending back five Taliban commanders held at Guantanamo Bay, and that it did not follow the law by consulting members of Congress ahead of time.

“Doing ‘everything possible’ in my mind does not include breaking the law and jeopardizing national security,” Nugent said in a written statement Thursday.

“It doesn’t mean the Commander in Chief should go give them a nuclear weapon or whatever else they want in exchange for Bergdahl. Basic judgment tells you that. People on both sides think he’s put our troops and our allies at undue risk” by sending back the Taliban leaders, Nugent said.

Nugent is one of several conservatives in Congress who have made a similar shift this week. First, they demanded that President Obama get Bergdahl back. Then, when the soldier was released, they blasted Obama for giving up too much to get him.

Those conservatives have been mocked by Democrats and cable-news talkers, who accuse them of playing politics. “It is clear they are worried his release could be seen as a victory for President Obama,” Senate Majority Leader Harry M. Reid (D-Nev.) said on the Senate floor Wednesday.

In interviews and statements, some in the group have said they did not contradict themselves. They always wanted Bergdahl back. They expected it might take a deal with the Taliban. Indeed, the broad outlines of this deal — including the five Taliban commanders to be exchanged — had been discussed publicly since at least 2011.

But still, these conservatives say, they didn’t expect the final deal would be this bad.

In February, The Washington Post reported on the revival of talks to free Bergdahl in exchange for releasing five Taliban commanders held at Guantanamo Bay, Cuba, into the custody of Qatar — the exact outlines of the deal that was eventually announced. When asked at the time by CNN’s Anderson Cooper about reports of such a deal, Sen. John S. McCain (R-Ariz.) said he might support an agreement for Bergdahl that included some kind of prisoner exchange.

“Obviously I’d have to know the details, but I would support ways of bringing [Bergdahl] home, and if exchange was one of them I think that would be something I think we should seriously consider,” McCain said.

But after Obama announced Saturday that he had swapped the Taliban prisoners for Bergdahl, McCain criticized the exchange as “a mistake.”

On Thursday, a spokesman for McCain said that if McCain had been presented with the offer that Obama accepted, he would have said no.

“What he was saying [in February] is, ‘I’d love to get this guy. I’d be inclined to support a deal. But it would obviously come down to what the terms are,’ ” said Brian Rogers, the McCain spokesman. “To take what he said and to suggest that he would support any deal is obviously unreasonable. He wouldn’t support anything.”

Other legislators who had supported Bergdahl’s release said they were outraged by how little Obama told Congress about the deal before it happened. The National Defense Authorization Act of 2014 requires that the administration notify Congress at least 30 days in advance of a Guantanamo detainee release.

In this case, that didn’t happen. Reid said he was given a one-day notice of the deal, but many other congressional leaders — including top Republicans — were not.

Sen. Tim Scott (R-S.C.), who had earlier supported a resolution calling for the United States to not leave soldiers behind in Iraq and Afghanistan,has criticized the way it was done.

“Senator Scott believes that we should leave no man or woman in uniform behind and that the President should follow the law,” a spokesman for Scott wrote Thursday. “These are not contradictory views; they are what both our troops and the American people as a whole deserve.”

The complications of Bergdahl’s case — the soldier apparently left his base voluntarily, was held captive by America’s enemy, then was returned in a deal that the Taliban celebrated — have left some politicians struggling to find the right way to react.

Several members of Congress from both parties issued tweets celebrating Bergdahl’s return, only to delete them as the story grew murky.

Others, even in Bergdahl’s home state of Idaho, have expressed both joy and concern about his return.

Just after Bergdahl’s release, Sen. Mike Crapo (R-Idaho) released a statement that said: “Our prayers have been answered and we offer our thanks for the perseverance of the family and the many Idahoans who have kept this vigil. We appreciate the men and women who made this release possible.”

Five days later, Crapo expressed doubts about the exchange, telling a local news outlet: “I believe that is a problem . . . that could potentially result in a problem for our national security.”