Senator John McCain’s campaign manager was paid more than $30,000 a month for five years as president of an advocacy group set up by the mortgage giants Fannie Mae and Freddie Mac to defend them against stricter regulations, current and former officials say.

Mr. McCain, the Republican candidate for president, has recently begun campaigning as a critic of the two companies and the lobbying army that helped them evade greater regulation as they began buying riskier mortgages with implicit federal backing. He and his Democratic rival, Senator Barack Obama, have donors and advisers who are tied to the companies.

But last week the McCain campaign stepped up a running battle of guilt by association when it began broadcasting commercials trying to link Mr. Obama directly to the government bailout of the mortgage giants this month by charging that he takes advice from Fannie Mae’s former chief executive, Franklin Raines, an assertion both Mr. Raines and the Obama campaign dispute.

Incensed by the advertisements, several current and former executives of the companies came forward to discuss the role that Rick Davis, Mr. McCain’s campaign manager and longtime adviser, played in helping Fannie Mae and Freddie Mac beat back regulatory challenges when he served as president of their advocacy group, the Homeownership Alliance, formed in the summer of 2000. Some who came forward were Democrats, but Republicans, speaking on the condition of anonymity, confirmed their descriptions.