Barack Obama played poker and basketball with lobbyists when he was a state senator. He took their campaign donations and worked with them to write legislation. But he also helped pass ethics laws to reduce sharply their influence.

A look at Obama's seven years in the Illinois Legislature reveals a complicated relationship with lobbyists — particularly for someone who now makes criticism of lobbyists a centerpiece of his presidential campaign.

The Illinois Democrat, now a first-term U.S. senator, argues that they have too much power in Washington. He has sworn off taking donations from Washington lobbyists and political action committees, while assailing rival Hillary Rodham Clinton for not doing the same.

"It's time we had a president who tells the drug companies and the oil companies and the insurance industry that while they get a seat at the table in Washington, they don't get to buy every chair. Not any more," he said earlier this year.

Obama hasn't always been so adamant about lobbyists and their money.

About 40 percent of the money he raised as a state senator came from PACs, corporations and unions, including organizations with a financial stake in legislation he was sponsoring.

For instance, Obama, who often sponsored legislation on health care and prescription drugs, took $5,650 from health-related groups, $8,900 from insurance groups and $3,000 from a lobbyist representing drug companies.

Meanwhile, PACs contributed 3.2 percent of the $490,285 he raised for an unsuccessful congressional bid in 2000, and 8 percent of the $15 million he raised for his U.S. Senate race in 2004.

But while in the state legislature, Obama was a relatively small fish when it came to Illinois political money.

He usually got donations of a few hundred dollars or maybe $1,000 in a state where interest groups routinely give key officials tens of thousands of dollars at a time.

Disclosure reports show he rarely accepted gifts or meals from lobbyists, even though there was no limit on such freebies until Obama helped pass a law establishing one. For him, a big gift was $50 worth of tickets to a Rembrandt exhibit from the Art Institute of Chicago.

Some lobbyists were even a bit hazy on who he was, spelling his name "O'Bama" in their reports.

Several Illinois lobbyists said Obama was always willing to hear them out, even if he was on the opposite side of an issue.

"His door was always open. There weren't many times we agreed on things, but he would listen," said Jay Dee Shattuck, a lobbyist for the Illinois Chamber of Commerce, a group that didn't make campaign donations to Obama.

In some instances, Obama didn't just listen to lobbyists. He worked with them to draft legislation, hammering out the specifics in long negotiations with lobbyists from both sides.

He used this approach to add safeguards to the state death penalty system and to prevent racial profiling in traffic stops, two touchy issues that involved law enforcement. Representatives from both sides say Obama took their concerns seriously and made concessions when they presented a good argument.

While Obama wasn't known for attending cocktail parties or dining with lobbyists, he did socialize with them.

Obama played basketball almost daily when the legislature was in session in Springfield and participated in a weekly poker game. His opponents included other legislators as well as some lobbyists. The lobbyists say they never discussed legislation during the game, but they did feel that establishing a rapport on the court or at the card table helped them with Obama in the long run.

Even friendly lobbyists could expect sharp questioning about their legislation.

"When you walked into his office, you'd better have all the facts," said Michael Lieteau, a lobbyist who played both basketball and poker with Obama. Lieteau lobbies for AT&T, which gave Obama at least $5,250 through its PAC.

Obama helped pass two of the toughest ethics laws in Illinois history, and both of them attempted to reduce the influence of lobbyists.

A 1998 law barred lawmakers from accepting most gifts from lobbyists. It also outlawed accepting campaign donations on state property, meaning lobbyists could no longer hand legislators a check just as they were entering the chamber to vote.

"Prior to that bill, if you wanted to give a legislator a car, you could," said Cynthia Canary, director of the Illinois Campaign for Political Reform. "That probably is the most significant curb we've put on in this state, and he was a key part of that."

Obama also co-sponsored a 2003 law that, among other things, barred lobbyists from serving on government boards and commissions and further tightened the restrictions on gifts to legislators.

After his election to the U.S. Senate, Obama was a leader in the successful effort to strengthen federal ethics laws. Lawmakers now have to disclose the names of lobbyists who raise money for them by "bundling" donations from many people. They also have to disclose special projects they try to add to the budget.

"Throughout his career, Barack Obama has fought to reduce the outsized influence lobbyists wield over the legislative process and to give a voice to underrepresented Americans," spokesman Ben LaBolt said in a statement.

He did not respond to questions about why Obama chose to accept lobbyists' donations in Springfield but rejects them now, except to say that Obama's ban is an imperfect solution to the problem of money in politics.

The ban is not absolute.

Obama's presidential campaign takes donations from state-level lobbyists and from the families and business partners of federal lobbyists. And Obama didn't adopt the ban until he ran for president. His Hopefund political committee accepted about $125,000 from PACs after he began serving in the U.S. Senate, and his Senate campaign committee also continued to accept PAC contributions until this year.

Canary doesn't see a contradiction between Obama's relationship with lobbyists in Springfield and his argument today that Washington lobbyists have too much clout.

One reason, she said, is that Illinois legislators have smaller staffs to research and write bills, so lobbyists must play a bigger part in explaining the issues. The real question is whether legislators give lobbyists too much authority, she said, and there's no indication of Obama doing that.

"I don't think it's bad to have those voices at the table, but it requires legislators to know what their own positions are and to do their homework," Canary said.