WASHINGTON — Despite leaving the country for more than a week, Sen. Barack Obama raised more than $51 million in July, keeping him in line to collect more than half a billion dollars for his 2008 presidential bid.

The showing, almost double what presumptive Republican nominee John McCain raised in the same month, was fresh evidence that Obama has maintained his record-setting pace after a contentious primary contest with Sen. Hillary Rodham Clinton, D-N.Y. It was also part of a larger trend in which Democratic candidates and party committees have been able to close the fundraising gap with their Republican counterparts.

Based on the figures the Obama campaign made public Saturday, the senator from Illinois has now raised about $400 million in his campaign for the White House, and his top aides believe funds could come in at an even faster rate when voters are paying closer attention to the contest in September and October. McCain's campaign announced Friday that the senator from Arizona raised $27 million in July, bringing his total to just over $170 million for the campaign to date.

During the 2004 primaries, by comparison, President Bush raised $258 million during the 2004 primary campaign, while Sen. John Kerry, D-Mass., raised $215 million before formally accepting the Democratic nomination. Obama's July figure represents the third-highest monthly fundraising total in history. His high-water mark came in February, when he raised $55 million.

While contributions flowing into Obama's campaign through the Internet have been credited with much of his fundraising success, he has also engaged in an aggressive courtship of the nation's wealthy elite. He now has at least 35 bundlers who have each raised more than $500,000 for his campaign.

And Obama's strong financial position has been accompanied by a broader wave of support for Democrats in other federal, state and local campaigns. On Friday, the Federal Election Commission released a review of party fundraising over the past 18 months that found Democratic Party committees have raised 25 percent more during this election cycle than at the same point four years ago. Republicans, by contrast, have seen a 12 percent decline.

The report shows total giving to Democratic Party accounts has increased from $278 million during the 2004 election cycle to $351 million so far this year. Republican Party donations have dropped during the same period, from $464 million to $409 million.

Tony Podesta, a top Democratic lobbyist, said he believes three factors are driving the Democratic fundraising numbers.

"One is Bush and the antipathy towards him. The second is Iraq and the antipathy towards the war. And the third is Obama, who has attracted a fervor that is very unusual in our politics," Podesta said.

The trend lines for Republicans are not all bad. The Republican National Committee reported Saturday it had $75 million in the bank at the end of July, less than four years ago but substantially more than the $28.5 million that the Democratic National Committee had in the bank at the end of last month. The DNC released numbers Saturday showing the party raised $27.7 million in July.

Republican officials point out that, when the RNC totals are combined with the $21 million in cash that McCain held at the end of July, they actually have slightly more money available for the White House contest than do Democrats. (Combined figures show Republicans with $96 million and Democrats with $94.3)

In a conference call with reporters on Friday, McCain campaign manager Rick Davis noted that the presumptive GOP nominee will have $84 million in federal funds and about $20 million in joint party funds that will be under the candidate's control. That, he said, will be more than sufficient to finance the two-month sprint from the Republican National Convention to Election Day.

The DNC has lagged behind the RNC in fundraising, representing one of the few financial trouble spots for Democrats.

Karen Finney, a DNC spokeswoman, said the national party entered this election cycle in debt after aggressive spending in the 2006 elections. She said the party had trouble raising money during the protracted presidential primaries but added that funds raised have been spent to build the foundation for a national campaign.

Another area in which Democrats have struggled in raising money is in preparation for the Democratic National Convention. The Denver host committee was having so much trouble coming up with its $60 million share of the convention costs that top Obama fundraisers have traveled to Denver in recent weeks to help bolster the effort.