CHICAGO — When Barack Obama announced to friends over brunch in 2002 that he planned to run for the United States Senate, one of their first questions was how he could possibly raise the necessary millions.

After all, two and a half years after he had taken quite a “spanking,” as he put it, in his bid to unseat an incumbent congressman, he was still struggling to pay off a $20,000 debt, eking out donations of $1,000 here, $2,000 there.

Improbably, Mr. Obama, running as something of an outsider, wound up raising $15 million and winning that 2004 Senate race. Now that he is running for president, his fund-raising prowess has helped make him the chief rival to Senator Hillary Rodham Clinton of New York.

[Aides said Monday that he had collected more than $20 million in donations in the first three months of the campaign, enough to ratchet up the anxiety in the Clinton camp, which announced it had raised $26 million. Mr. Obama’s campaign has yet to release precise information on its total donations or contributors.]

A look at his 2004 Senate race shows how he laid the foundation for his current fund-raising drive. Even as he cultivated an image as an unconventional candidate devoted to the people, not the establishment, he systematically built a sophisticated, and in many ways quite conventional, money machine.

Interviews and campaign finance reports show Mr. Obama drew crucial early support from Chicago’s thriving black professional class, using it as a springboard to other rainmakers within the broader party establishment. Soon he was drawing money — and, just as valuable, buzz — among wealthy Chicago families like the Crowns and the Pritzkers, as well as friends from Harvard Law School and the University of Chicago, where Mr. Obama taught constitutional law and his wife worked in community relations. As his popularity surged after his rousing speech at the Democratic National Convention in July 2004, big fund-raisers on Wall Street and in Hollywood hopped aboard, and grass-roots contributions began pouring in as well.

Mr. Obama has written that at the beginning he felt uncomfortable asking for money, but he developed a skill at cultivating donors, often with the same disarming directness he uses on the campaign trail.

“I met him on the first hole,” Steven S. Rogers, a former business owner who teaches at the Kellogg School of Management at Northwestern University, recalled recently about a golf game in 2001. “By the sixth hole, he said, ‘Steve, I want to run for the Senate.’ And by the ninth hole, he said he needed help to clear up some debts.”

Mr. Obama’s breakthrough in the 2004 Senate race was also made possible by a new wrinkle in the election laws. Faced with a self-financed opponent in the Democratic primary, Blair Hull, who pumped more than $28 million of his own money into the race, Mr. Obama was able to accept up to $12,000 from each donor, or six times the limit at that time.

As a result, nearly half of the more than $5 million that Mr. Obama raised in the primary came from just 300 donors. In a stroke of luck, he had just enough money to pay for a television advertising blitz in the final weeks as Mr. Hull’s campaign crumbled amid accusations that he had abused a former wife.

Some longtime Obama donors said they were glad to be able to exploit the financing loophole to help him.

James S. Crown, a senior member of the Crown family, said that despite the “formidable competition” in the Senate primary, he was so impressed after meeting Mr. Obama for breakfast in early 2003 that he quickly lent his support.

“I was just taken with his sensibility, his intelligence, his values and how he conducted himself during that campaign,” said Mr. Crown, who is Mr. Obama’s chief presidential fund-raiser in Illinois.

Mr. Obama appears to have such a firm hold on so many of Chicago’s big donors that Mrs. Clinton, who grew up in a Chicago suburb, did not even have a fund-raiser here during the crucial first quarter of this year. At the same time, Mr. Obama’s campaign says its grass-roots support is expanding rapidly, in part through $25-a-ticket fund-raisers designed for a new generation of donors.

Mr. Obama declined to be interviewed for this article. But in his book “The Audacity of Hope,” he sounded prescient about the dangers of the money chase, noting that he could not assume it “didn’t alter me in some ways.” At the simplest level, he wrote, it “eliminated any sense of shame” about asking for donations.

But, he added, he also worries that spending so much time courting wealthy donors has caused him to spend “more and more time above the fray,” away from the concerns of ordinary voters.

Mr. Obama, who grew up mostly in Hawaii, began making political contacts in Chicago as a community organizer in the 1980s. After graduating from Harvard Law School in 1991, he returned to Chicago and led a drive that registered more than 100,000 voters for the 1992 elections.

Mr. Obama asked John R. Schmidt, a lawyer who was co-chairman of Bill Clinton’s Illinois fund-raising operation, to raise money for the voter drive. Mr. Schmidt said he invited donors to meet Mr. Obama over lunch at the University Club of Chicago, and he and some of the others later became major donors to his political campaigns.

But perhaps Mr. Obama’s most crucial early support came from the city’s longstanding cadre of highly successful black executives and entrepreneurs.

John W. Rogers Jr., chief executive of Ariel Capital Management, which oversees $16 billion in investments, played basketball with Mr. Obama’s brother-in-law at Princeton University. Quintin E. Primo III, who made a fortune financing commercial real-estate deals, and Louis A. Holland, an investment manager, have also contributed to nearly all the senator’s races.

Under its first black mayor, Harold Washington, the City of Chicago had expanded its contracts with minority business in the 1980s. But, Mr. Rogers said, the state “was not as open and inclusive as it could be.” As a state senator, he said, Mr. Obama pushed to open up more contracting and to give minority investment companies a greater stake in managing state pension funds.

When Mr. Obama decided to run for Congress in 2000 against the former Black Panther Bobby Rush, he used a $9,500 personal loan to help finance the campaign. When he lost, he found himself broke and fielding questions from the Federal Election Commission about his campaign finances. He later had to lend his campaign committee $11,100 more to cover refunds to donors who had inadvertently given too much.

An error has occurred. Please try again later.

You are already subscribed to this email.

It took him two years to repay his own loans, mostly with small checks from black executives who agreed to help him prepare for another run.

Robert D. Blackwell Sr., a management consultant whose family contributed a few thousand dollars to Mr. Obama then, said that after the House race, it would have been natural for some supporters to hesitate.

“But Barack has almost devout followers who are people of action,” Mr. Blackwell said, “and they rallied behind him.”

When Mr. Obama told his closest friends about his Senate plans, Valerie Jarrett, a Chicago businesswoman who led his finance committee, said: “Our initial reaction was, ‘It’s too soon. You just lost, and if you lose again, where are you?’ ”

Ms. Jarrett said Mr. Obama replied that he was willing to gamble all on one more shot. David Axelrod, Mr. Obama’s strategist for his Senate and presidential campaigns, said Mr. Obama believed that if he polled well among blacks and white liberals, he would have a chance.

At least initially, few donors seemed to agree. Besides Mr. Hull, a former securities trader, another opponent was the state comptroller, Dan Hynes, whose father had been a major Illinois political figure.

After three months of calling longtime supporters and other Democratic donors, Mr. Obama had raised only $250,000. Even some Harvard friends were wondering if the race made sense.

David B. Wilkins, a Harvard law professor and friend of Mr. Obama, recalled, “I held one of his first fund-raisers here in Cambridge, and I had to beg people to come, because they said: ‘What is this? This guy thinks he’s going to win? Come on.’ ”

At first, only a handful of Obama supporters took advantage of the increased contribution limits, newly available under a so-called millionaire’s amendment to federal campaign laws.

From his Chicago circle of black professionals came John Rogers, who gave $11,000. Among the other investment managers, Mr. Primo and his wife gave $18,000. And Mr. Holland, his wife and two of his partners donated a total of $35,000.

At Harvard, Mr. Wilkins helped tap into professors and alumni, including George Haywood, an investor who, with his wife, Cheryl, contributed $12,000 in April 2003.

Mr. Haywood and Mr. Obama became friends, and it was Mr. Haywood whom then-Senator Obama turned to in early 2005 when he needed a broker to help manage money from a book deal. Mr. Haywood’s broker later invested $100,000 of Mr. Obama’s cash in two speculative stocks that Mr. Haywood owned.

Antoin Rezko, a Chicago businessman who was later involved in a land deal with the Obamas, gave $10,500.

Mr. Obama’s support also widened among Chicago’s business elite. Members of the Pritzker family, which founded the Hyatt Hotel chain, donated $40,000; Penny Pritzker is now the senator’s national finance chairwoman.

Mr. Crown, whose family’s investments include a major stake in the military contractor General Dynamics, said family members normally avoided taking sides in a primary, in part because it was not good for business. But with Mr. Obama, they made an exception, with 10 family members giving a total of $112,500.

“I was just so personally impressed with Barack that it was worth the risk,” Mr. Crown said.

Mr. Obama also attracted major national Democratic donors, including George Soros and members of his family, who gave a total of $60,000.

Other major donors included executives at a Texas-based securities firm, Tejas Inc., who gave $56,000. Its chairman, John Gorman, told The Austin American-Statesman in 2004 that he had been introduced to Mr. Obama by Vernon E. Jordan Jr., the Washington power broker.

Though he helped raise money for Mr. Obama in 2004, Mr. Jordan, a longtime Clinton friend and confidant, is now aligned with Mrs. Clinton’s presidential campaign. In fact, many people who once backed both Mr. Obama’s Senate campaign and the Clintons are now having to choose sides.

Some traditional Clinton supporters, including the Rev. Jesse Jackson, David Geffen, the Hollywood mogul, and Michael Froman, a Citigroup executive, have migrated to Mr. Obama.

And Chicago has become almost completely an Obama town. Though Democrats here still express respect for Mrs. Clinton, "if she’s raising any money in Chicago, I don’t know who’s doing it," said Mr. Schmidt, the lawyer who was once co-chairman of President Clinton’s fund-raising here.

A version of this article appears in print on , on Page A1 of the New York edition with the headline: After 2000 Loss, Obama Built Donor Network From Roots Up. Order Reprints|Today's Paper|Subscribe