For roughly six years, Newt Gingrich worked closely with high-level officials at the government-sponsored mortgage company Freddie Mac. As a highly paid consultant, he coached them on how to win over the conservatives who consider their company an anathema, spoke to their political action committee and offered general advice as they worked to stave off various threats to Freddie Mac’s survival, several people familiar with his role there said Tuesday.

The full extent of Mr. Gingrich’s involvement with Freddie Mac burst into the open after Bloomberg News reported Tuesday that he earned $1.6 million to $1.8 million, in an on-and-off relationship from 1999 to 2008, with the mortgage company that has since been taken over by the federal government. The payments were far more than had previously been known, or than Mr. Gingrich, the former House speaker, had previously acknowledged.

His compensation, which several former Freddie Mac officials confirmed in interviews on Tuesday, and the extent of his work with the mortgage company, presented Mr. Gingrich with a fresh challenge to his Republican bid for the presidency just as he was climbing in polls and gaining traction as a possible challenger to the party’s presumed front-runner, Mitt Romney.

Not only is Freddie Mac a longtime conservative whipping post, but the extent of his consultancy for the mortgage giant seemed to be at odds with his own statements about his work there. He has also blamed it for the collapse of the housing market, saying that at least one Democratic supporter should be jailed, and, in 2008, that President Obama should give back any money his campaign received from its executives.

The news of the full extent of his Freddie Mac contract put him on the defensive all day.

“Fannie and Freddie, as you know, have been the epicenter of the financial meltdown in this country,” said Representative Michele Bachmann of Minnesota, while campaigning in Iowa. “While he was taking that money, I was fighting against Fannie and Freddie.”

Speaking with reporters in Iowa on Wednesday, Mr. Gingrich played down the report, saying that he did not know exactly how much he was paid, and that Freddie Mac was but one company that enlisted his firm, the Gingrich Group.

“It’s a multiyear project. It was paid to Gingrich Group. Gingrich Group has many clients,” Mr. Gingrich told reporters. “I offer strategic advice for a lot of different companies.” (His campaign followed up by listing some of them, including I.B.M.,Microsoft and the U.S. Chamber of Commerce.)

And, he said, “I did no lobbying of any kind.”

In interviews on Tuesday, several former Freddie Mac officials, and others with direct knowledge about his work there did not dispute that. But at least four of them did dispute Mr. Gingrich’s own description of his work for Freddie Mac during the CNBC debate last week. When asked about a $300,000-per-year, two-year contract in 2006 and 2007, Mr. Gingrich said he had acted as an “historian.”

He said Freddie officials had come to ask his advice, as an historian, telling him, “We are now making loans to people who have no credit history and have no record of paying back anything, but that’s what the government wants us to do.”

And, he explained: “As I said to them at the time, this is a bubble. This is insane. This is impossible.”

Five officials with knowledge of his interactions, and speaking on the condition of anonymity to avoid getting drawn into a public fight with him, said they had never heard of him saying any such thing.

“Freddie wasn’t spending $25,000 to $35,000 a month for years to have somebody give them history lessons on what would have happened in 1945 if Japan had won,” one former official said.

Another said Mr. Gingrich was enlisted at a time when conservatives were moving aggressively to dismantle Freddie and its counterpart,Fannie Mae, and the organizations were trying to fight back by presenting themselves “as American as apple pie.”

Officials said Mr. Gingrich was brought in to help Freddie Mac hone its message to conservative audiences. One person recalled that Mr. Gingrich advised them, for instance, to tell Republicans that the organization was not explicitly government backed — and, at the time, it was not — but also not as freewheeling as Wall Street banks, occupying a responsible middle ground.

Fannie Mae and Freddie Mac were commonly referred to as government-sponsored entities. They were established by Congress, and their debt and other obligations have always carried an implicit guarantee that the federal government would step in to save them if they were ever in danger of collapse. Republicans said that the companies — and by implication their Democratic supporters — fueled the crisis by financing vast numbers of unaffordable loans.

In all, Mr. Gingrich served two terms as a consultant to Freddie Mac, the first starting shortly after he left the House in 1999. Hired by the head of the mortgage company’s government affairs shop, Robert Mitchell Delk, he stayed on through 2002. In an interview with Bloomberg, Mr. Delk said Mr. Gingrich helped him prepare to meet with White House officials to discuss President George W. Bush’s “ownership society.”

Two other officials said that during his second run with the group, when he took a two-year contract starting in 2006, he addressed donors to the Fannie Mac political action committee and discussed writing an op-ed article or academic “white paper,” but never wound up putting his name on anything on Freddie’s behalf.

Mr. Gingrich has in recent months been harshly critical of those who have worked with Freddie Mac and Fannie Mae. For instance, he said, Representative Barney Frank, Democrat of Massachusetts, should be jailed for his association with “a lobbyist who was close to Freddie Mac.”

On Tuesday, his campaign said that Mr. Gingrich “believes the financial crisis shows that Fannie Mae and Freddie Mac should be broken up and their smaller successors be moved off of government guarantees and into the free market.”

For his part, Mr. Gingrich said he welcomed the scrutiny. “Everybody will dig up everything they can dig up,” Mr. Gingrich said. “That’s fine; they should.”

Trip Gabriel, Charles Duhigg and Kitty Bennett contributed reporting.