Known as government-sponsored enterprises, they didn’t provide mortgages themselves, but rather bought loans from banks and mortgage brokers, freeing up cash so the lenders could make more loans. Fannie and Freddie held or bundled the loans and sold them to investors as mortgage-backed securities.

That mess has a long history. The government created Fannie Mae in 1938 to make mortgages more affordable, and its cousin Freddie Mac came along in 1970. Congress allowed them to operate as private companies.

Another analyst, University of Maryland economics professor Peter Morici, put it more succinctly. “This is a bipartisan mess,’’ he said.

“Selling Fannie and Freddie as a purely partisan issue, it doesn’t really work,’’ said Jonathan Koppell, director of the School of Public Affairs at Arizona State University. “Both parties have plenty of responsibility.’’

But Frank said that putting blame entirely on him is unfair — and several independent analysts agree. They said Republicans also failed to take warning signs seriously enough to avert disaster, despite controlling the White House and both houses of Congress between 2003 and 2007, a crucial period leading up to the Fannie and Freddie failures.

Republican Sean Bielat, who is trying to unseat Frank, has been hammering away at him with a website titled “Retire Barney’’ that features clips of Frank at the 2003 hearing and elsewhere. During debates this week, he called Frank “one of the leaders of the economic disaster’’ because he supported Fannie and Freddie when they were taking the risks that led to their collapse.

“I was late in seeing it, no question,’’ Frank said about the lenders’ descent into insolvency.

Frank, in his most detailed explanation to date about his actions, said in an interview he missed the warning signs because he was wearing ideological blinders. He said he had worried that Republican lawmakers and the Bush administration were going after Fannie and Freddie for their own ideological reasons and would curtail the lenders’ mission of providing affordable housing.

Now, it’s clear he was wrong on both points — and that his words have become a political liability as he fights a determined challenger to win a 16th term representing the Fourth Congressional District. Fannie and Freddie collapsed in 2008, forcing the federal government to buy $150 billion worth of stock in the enterprises and $1.36 trillion worth of mortgage-backed securities.

The issue that day in 2003 was whether mortgage backers Fannie Mae and Freddie Mac were fiscally strong. Frank declared with his trademark confidence that they were, accusing critics and regulators of exaggerating threats to Fannie’s and Freddie’s financial integrity. And, the Massachusetts Democrat maintained, “even if there were problems, the federal government doesn’t bail them out.’’

WASHINGTON — When US Representative Barney Frank spoke in a packed hearing room on Capitol Hill seven years ago, he did not imagine that his words would eventually haunt a reelection bid.

In an effort to increase homeownership, the Clinton administration in the late 1990s and the Bush administration in the 2000s pushed Fannie and Freddie to meet growing quotas for buying affordable home loans. Those pushes, combined with a drive for more profits at the enterprises, drove Fannie and Freddie to take on more risk and more debt. They backed subprime and other risky loans, including mortgages for borrowers without proof of steady income.

At the same time, Fannie and Freddie were spending $155 million on a massive lobbying operation seeking to thwart any crackdown on their operations.

They poured $4.2 million into congressional campaign coffers in the years before they collapsed, according to the Center for Responsive Politics. Their executives, lobbyists, and political action committees donated to both Republicans and Democrats, including Frank, who received about $65,000 between 2000 and 2008, a Globe review of individual contributions found.

But the director of the federal office responsible for overseeing Fannie and Freddie, Armando Falcon, began noticing their expanding portfolios and increasing reliance on risky investments. In early 2003, Falcon warned Congress in a 118-page report of the companies’ potential for a catastrophic failure that could jeopardize the economy.

Falcon sent his report to Frank and other Financial Services Committee members and asked that Fannie and Freddie be required to disclose more about their finances and be subject to tougher oversight. He followed it up with another report in June 2003.

A few months later, the Bush administration said it would try to rein in the enterprises by creating a regulatory authority within the Treasury to oversee them.

The warning signs were compounded by revelations in 2003 and early 2004 that Freddie Mac and Fannie Mae had misstated earnings by billions of dollars in an effort to meet growth targets.

But Frank and other Democrats still opposed tighter regulation, Frank most notably in his public statements saying there was nothing wrong with Fannie and Freddie. He and other House Democrats also sent a letter to President George W. Bush in June 2004, saying the proposed crackdown could “weaken affordable housing performance . . . by emphasizing only safety and soundness.’’

Frank, who became ranking minority member of the Financial Services Committee in January 2003, says now he doesn’t remember Falcon’s reports.

“I had just taken over as ranking member, all this stuff was very new to me,’’ he said.

Frank tried to tackle Fannie’s and Freddie’s problems from another angle, he said, introducing a predatory lending bill in spring 2004 that would reduce subprime loans. But the legislation did not address the voracious quest for profits or other problems at the mortgage lenders.