As Spain edged closer to a real estate and banking crisis that led to its recent bank bailout, Spanish financial leaders in influential positions mostly played down concerns that something might go terribly wrong.


The optimism of Spanish central bankers who went on to top jobs at the International Monetary Fund echoes the attitudes of officials in the United States who misjudged the force of a housing collapse several years ago that crippled banks and the economy. And it underscores the complications that can arise when government officials take watchdog roles at international agencies that pass judgment on the policies they once directed.


Spain’s travails have now become central to the festering financial problems in Europe. The country’s biggest mortgage lender has failed, and European leaders are scrambling to prevent the Continent’s crisis from spreading further.


“The I.M.F. should be saying unpleasant things to countries to get them to reform,” said Jonathan Tepper of Variant Perception, a London-based research firm that in 2009 published one of the first reports to warn that Spanish banks were in serious trouble. “They have been quite late in Spain.”


From their lofty perches, first at Spain’s central bank and then as the I.M.F.’s top executives assessing global banking risk, José Viñals and Jaime Caruana were well positioned to sound alarms about the looming bank debacle.


But at a news conference in Washington in April 2010, when analysts were raising red flags about failing Spanish real estate loans, Mr. Viñals — who a year earlier had succeeded Mr. Caruana — offered assurances. The Spanish system was “fundamentally sound,” he said, and its needs for cash “very small.”


A year later, as the banking crisis showed little sign of improving, Mr. Viñals again called for calm, saying the market panic that had led to bailouts in Ireland and Portugal would not infect Spain.


Now that the recent failure of Bankia, the big mortgage lender, has prompted a 100 billion euro (about $125 billion) European rescue, it is clear that Mr. Viñals’s forecasts were too sanguine.


Mr. Caruana was no more prescient. Pressed at an I.M.F. news conference in July 2008 about falling house prices in Spain, he acknowledged there might be loan losses. But he said, “The financial system in Spain is able to cope with that and is properly capitalized.”


It is not that the I.M.F. was not paying attention. Under Mr. Caruana and then Mr. Viñals, the organization’s economists produced thousands of pages of analysis that, in real time, chronicled Spain’s unspooling bank crisis.


The I.M.F. says that it is not a regulator and that its economists and officials warned early and often on the need for Spain and Europe to address its banking problems.


In assessing financial risks worldwide, Mr. Viñals highlighted challenges faced by savings banks, or cajas, and he backed the efforts of his former colleagues at the Bank of Spain to bring order to the sector — such as the merger of seven cajas to form Bankia in 2010 — although he often urged them to move faster.


Certainly, Spanish officials were slow to acknowledge the depths of the problem.


In early May, Rodrigo Rato, then the executive chairman of Bankia, told journalists that the bank was in a situation of “great robustness, both in terms of solvency and liquidity.” Even after the bank’s bailout a few days later, Spain’s economy minister predicted that no more than 15 billion euros of public funds would be required to clean up the banks.


Mr. Caruana and Mr. Viñals, who declined to comment for this article, were not the only government officials to make the transition from Madrid to the I.M.F.’s headquarters in Washington.


Most prominent by far was Mr. Rato, now better known for his disastrous two-year run at the helm of Bankia. In 2004, he was picked to lead the I.M.F. after winning global recognition during an eight-year run supervising Spain’s growth burst as the country’s economy minister.