It was a dark time for the city. In 2008, and early into the next year, morale was low, Wall Street was sputtering and Mayor Michael Bloomberg was steeling New Yorkers for pain. Brace for service cuts and tax hikes, he warned — while also pledging to find a way to keep tax money, particularly from the city’s richest citizens, from fleeing.

“I’ve said this before, but the first rule of taxation is, you can’t tax too much those that can move,” Mr. Bloomberg intoned on a radio show late in the crisis. “You know, we’re yelling and screaming about the rich. We want the rich from around this county to move here. We love the rich people.”

And yet the richest New Yorker of them all — Mr. Bloomberg himself — had been ignoring his own advice.

According to an extensive review of the mayor’s financial records by The Observer, even as Mr. Bloomberg was trying to counter the loss of taxes and other income from the richest New Yorkers, the foundation he controls was in the process of shuttling hundreds of millions of dollars out of the city and into controversial offshore tax havens that would produce nothing at all for the city in terms of tax revenue.

By the end of 2008, the Bloomberg Family Foundation had transferred almost $300 million into various offshore destinations — some of them notorious tax-dodge hideouts. The Caymans and Cyprus. Bermuda and Brazil. Even Mauritius, a speck of an island in the Indian Ocean, off the coast of Madagascar. Other investments were spread around disparate locations, from Japan to Luxembourg to Romania.

Why was the mayor’s flagship foundation sending hundreds of millions of dollars offshore? Neither the charity nor the mayor will explain. What is clear is that the issue could get prickly for Mr. Bloomberg, in part because his investment strategies have been so closely associated with Steve Rattner, the onetime boy wonder financier who remains under investigation by Attorney General Andrew Cuomo for his involvement in a state pension controversy. Last week, Mr. Rattner’s former firm, Quadrangle Group, took the extraordinary step of excommunicating him, saying in a statement that it “wholly disavow[ed]” Mr. Rattner over his role in securing state pension contracts — conduct the company called “inappropriate, wrong, and unethical.”

On December 26, 2007 — the same day that the city’s Conflicts of Interest Board opened the door for Mr. Rattner’s firm to manage the foundation’s money — the foundation immediately sent $210 million to a new fund — “QAM Select Investors (Offshore) Ltd.” — based in the Cayman Islands.

A month later, the foundation was given clearance to allow two city workers to use municipal time and resources on foundation work — on the assumption that the charity would “ultimately serve the city” and “further the interests and purposes of the city.”

And what of the benefit that was supposed to come New York’s way as a result of all of these millions? Mr. Bloomberg donated more than $1.8 billion to the foundation in its first three years of life, according to the foundation’s tax filings. About $67 million — $36 million in 2007 and $31 million in 2008 — was given away. Much of it went to anti-smoking initiatives, including the World Lung Federation and an Indian anti-smoking group; other grants went to the government of Vietnam and the World Health Organization, for injury-prevention efforts. No grants went to organizations directly benefiting New York City.

Today, at a five-story Beaux Arts mansion on the corner of 78th Street and Madison, workers are putting the finishing touches on the foundation’s new headquarters, which Mr. Bloomberg purchased for $45 million. Flatbed trucks unload marble tiles for the building’s floors; electricians have installed subdued lighting and a heavy, automatic glass sliding door.

Several weeks ago, the foundation named a new 19-person board that reads like a who’s who of national politics and finance: Former Florida governor Jeb Bush, former Georgia senator Sam Nunn and former Treasury secretary Hank Paulson are among the members. It is all part of a push by Mr. Bloomberg to put the foundation on a par with other big charities and put his name on the list of America’s great philanthropists: Gates, Carnegie, Rockefeller and Ford have their foundations, and now so does Bloomberg.

Beyond the U.S. border, in places like the Caymans, the climate for charities is much more inviting. Nonprofits like the Bloomberg Family Foundation are tax-exempt, but some investments that aren’t related to an organization’s core mission can be subject to a levy called the Unrelated Business Income Tax (UBIT, for short). So to avoid more than 40 percent in federal and local taxes on unrelated businesses, nonprofits use a legal loophole, routing investments through offshore tax havens.

“It cleanses the unrelated business taint from the total return,” Harvey Dale, of the N.Y.U. School of Law, told The Observer. “You invest in the same thing through an offshore entity. You are making the same investment; you are just putting an intermediary entity in the middle. Instead of investing directly in the hedge fund, you invest in the foreign entity, which, in turn, invests in the hedge fund.”

“Is (using the loophole) allowable under the law? Yes,” said tax expert Dean Zerbe, a former staffer at the Senate Finance Committee. “Is it something that is a best practice, particularly by an elected official? I think they should look very hard when they are engaging in this kind of activity. What does it say to the average New Yorker?”

The foundation’s tax returns indicate that Mr. Rattner’s team migrated much of its money to large hedge funds with ostensible island charters, including several in the Caymans, two of which list an address at P.O. Box 309 of the Ugland House, a building that “houses” an estimated 12,000 to 18,000 foreign businesses.

“Now, that’s either the biggest building in the world or the biggest tax scam in the world,” said Senator Barack Obama during his campaign for president. “And I think we know which one it is.”

But tax havens — despite the protestations of the president, a slew of senators and at least one district attorney — remain legal. “I made a lot of effort to shut down that loophole,” former district attorney Robert Morgenthau told The Observer.

Mr. Morgenthau said he’d spoken generally about offshore loopholes to four U.S. secretaries of the Treasury, twice to the commissioner of the general revenue and, as it happens, to Mr. Bloomberg himself. The mayor seemed uninterested in the offshore issue, he said. “I’ve talked to the mayor about it, and the budget director,” Mr.

Morgenthau said. “We did get help from the State Division of Taxation and Finance. But nothing from the city.”

In spite of the flurry of investments, it appears that for years, Mr. Bloomberg’s foundation had no office, phones, staff, Web site or public brochures. In late 2007, the mayor wrote a second letter to the Conflicts of Interest Board, looking for another blessing: Some of his staffers at City Hall, he argued, were asking him, “unsolicited,” if they could help with his foundation. Saying that the foundation would “ultimately serve city goals,” the board approved. At least three of his staffers were even allowed to use government resources, like office space, phones and Internet service, for foundation work.

One of the staffers was Deputy Mayor Patricia Harris. Aside from Mr. Bloomberg, Ms. Harris was the sole officer listed on his foundation’s tax return. A longtime Bloomberg loyalist, Ms. Harris worked at Bloomberg LP before joining the mayor at City Hall. On foundation tax returns, Mr. Bloomberg and Ms. Harris each claimed to have spent .25 hours, or 15 minutes, per week on the charity — as it gave away tens of millions.

Last month, the mayor announced that Ms. Harris would take on even more duties at the foundation, although it is unclear if she will increase her time commitment.

The mayor’s press office referred all questions about the foundation to the organization’s press office, run by former mayoral aide James Anderson. “In order to avoid conflicts, the Mayor is neither involved in nor apprised of the specific investment decisions made on behalf of the foundation — and we are therefore not in a position to discuss them,” Mr. Anderson wrote in an email.

Yet Mr. Bloomberg does often discuss his charitable endeavors. “Other than Gates, nobody’s given away this amount of money,” he boasted to the New York Post‘s editorial board earlier this month.

But the Bill and Melinda Gates Foundation provides a contrast in its investment style. While the Bloomberg Family Foundation is hardly alone in embracing the savings provided by the offshore loophole — according to a 2007 New York Times piece, large universities like Yale and Duke, along with charities like the Rockefeller Foundation, engaged in the practice — The Times also reported that the Gates Foundation did not invest in offshore hedge funds.

“When instructing the investment managers, Bill and Melinda also consider other issues beyond corporate profits, including the values that drive the foundation’s work,” explains the Gates Foundation’s Web site. “They have defined areas in which the endowment will not invest, such as companies whose profit model is centrally tied to corporate activity that they find egregious.”

Mr. Rattner’s Quadrangle Group wasn’t beholden to any such strictures relating to the Bloomberg Family Foundation’s portfolio, and throughout 2008, the foundation made liberal use of the offshore loophole.

The bulk of the investments ended up in the Caymans. The Rattner team transferred more than $71 million dollars to Highfields Capital Ltd., the Caymans arm of a Boston-based hedge fund. (Last month, Highfields’ co-founder, Richard Grubman, was arrested after he allegedly beaned a Ritz Carlton valet with the keys of his BMW.) Another $67.8 million went to Brookside Cayman Ltd, the island home of Brookside Capital.

Other money decamped for even more exotic locales: $710,000 zipped to the tiny Grand Duchy of Luxembourg. Another $700,000 went to two funds on the island nation of Mauritius, about 500 miles east of Madagascar in the Indian Ocean. A Brazilian hedge fund got $304,000.

Mystique surrounds even some of the smaller foreign investments. In one, the mayor’s foundation transferred $104,000 in cash to a Cyprus-based oil services firm called Geotech Oil Services Holdings Ltd., controlled by a Russian oligarch named Nikolai Levitsky; Mr. Levitsky was once the first deputy governor of the resource-rich Komi Republic in Russia’s Northwest.

Reached by phone, Geotech spokesman Denis Cherednichenko said he had no idea if the Bloomberg Family Foundation had invested in the company, but seemed surprised. He speculated it could have been through another hedge fund. He said three American funds invested in Geotech in 2007.

In another transaction, Mr. Rattner’s team invested $560,000 of the mayor’s charitable fund in BJJ Universul, a Cyprus-based company that develops real estate in central Eastern Europe. According to its Web site, BJJ was established in Romania in 2004 and has more than 40 employees, split between Bucharest and Sofia, Bulgaria, and focused on “greenfield and redevelopment opportunities in Eastern Europe with a current focus on Romania and Bulgaria.”

Compared with those of the great foundations of America, the Bloomberg investment strategies stand out. “I’ve never seen anything like it. It’s about as opaque set of investments as you can find,” said Rick Cohen, who covers foundations and charities for Nonprofit Quarterly, and who agreed to review the foundation’s tax return. “This involves extensive investments in hedge funds offshore, where the motivation and purpose is not discernible, so you can’t tell what kind of activity it is or who is going to benefit from the investments.”

One former state official, however, defended the activity. “I don’t think there is anything unusual here,” said Bill Josephson, who headed the state’s Charities Bureau when Eliot Spitzer was attorney general, and examined the tax returns for The Observer.

“It is impossible to look at this and determine the intent of the hedge funds investments. You can’t figure it out from the 990 [tax form],” Mr. Josephson said. “The Bloomberg foundation is not that significantly different from the foundations of other individuals who come out of the investment world.”

The mayor announced some time ago that he would strip his funds from the Quadrangle Group, while allowing many of the Quadrangle managers who tended to his money to continue to do so at another firm. Quadrangle continues to manage about $100 million in New York City pension funds, according to the comptroller’s office.

As for the increasingly isolated Mr. Rattner, who remains under investigation, the mayor stands by him. “He’s a friend whose advice the mayor has, and continues to, rely on,” said a Bloomberg spokesman. Mr. Rattner declined to comment.

While almost nothing is known about the foundation’s investments since 2008, Mr. Bloomberg is now preparing to burnish his place in the annals of philanthropy. What exactly that means is not yet public.

Research support for this article was provided by the Investigative Fund of The Nation Institute.

Additional reporting by Azi Paybarah and Reid Pillifant.