By Megan Cassella and James Oliphant

WASHINGTON (Reuters) - U.S. Democratic presidential candidate Bernie Sanders regained access to crucial voter files on Friday after taking the Democratic National Committee to court and accusing party leaders of trying to undermine his White House bid and help rival Hillary Clinton.

The DNC had blocked access to the voter data after a Sanders campaign staffer improperly accessed Clinton's voter files, prompting charges of theft from the Clinton campaign and setting off a bitter political fight in what had been a relatively peaceful Democratic nominating race.

The DNC agreed to restore access to the files after Sanders sued the committee in U.S. District Court, accusing it of improperly suspending the campaign's access to the voter data. The DNC said the Sanders campaign had supplied information about the breach and promised to cooperate with an investigation.

"Based on this information, we are restoring the Sanders campaign’s access to the voter file, but will continue to investigate to ensure that the data that was inappropriately accessed has been deleted and is no longer in possession of the Sanders campaign," DNC Chairwoman Debbie Wasserman Schultz said in a statement.

The political brawl came one day before a debate between the presidential rivals, fueling rising tensions and highlighting complaints from Sanders and his liberal allies that the DNC is trying to help Clinton, particularly by limiting the number of debates and scheduling them on low-viewership periods like Saturday nights.

"In this case it looks like they are trying to help the Clinton campaign," Sanders campaign manager Jeff Weaver said at a news conference on Friday afternoon before filing the lawsuit. He accused the DNC of taking the Sanders campaign "hostage" by blocking its access to the files.

"We need our data, which has been stolen by the DNC. That's what we want back," Weaver said.

Clinton campaign manager Robby Mook told reporters in a conference call the Sanders staff had taken vital data that constituted a "strategic road map" for the campaign's voter turnout models and strategies.

Story continues

"The Sanders campaign stole data from our campaign," Mook said. "There is some damage here that cannot be undone."

The Sanders campaign said the breach of the confidential files, which contain information such as past voting and donation history, was an isolated incident and fired a staffer involved. It blamed the breach on the DNC's software vendor, Washington-based NGP VAN, for dropping the firewall between the various Democratic candidates' data.

The DNC rents access to its master voter list to campaigns, which augment the data with their own information. The firewalls are supposed to block campaigns from spying on their rivals.

An audit released by the Clinton campaign showed the breach was more extensive than the Sanders campaign described, with at least 24 occasions when the Sanders campaign "saved" lists of Clinton data, from four different users.

"We are asking that the Sanders campaign and the DNC work expeditiously to ensure that our data is not in the Sanders campaign's account," Clinton campaign spokesman Brian Fallon said.

Sanders campaign spokesman Michael Briggs called the allegation of theft "outrageous" and said the campaign did not keep or use any of the voter data.

"We are not aware of one piece of data in the possession of our campaign that resulted from the DNC vendor’s firewall failure," Briggs said.

FULL ACCESS FOR WEEKEND

He said the campaign would have full access to the voter files again on Saturday morning, in time for a weekend of campaigning.

The incident comes at a bad time for Sanders, the U.S. senator from Vermont who is trying to stop the heavily favored Clinton from running away with the party's 2016 presidential nomination. Sanders has been lagging behind Clinton, with 29 percent support to her 60 percent in recent Reuters/Ipsos polling.

Sanders, Clinton and a third candidate, former Maryland Governor Martin O'Malley, will debate at St. Anselm College in Manchester, New Hampshire, on Saturday night.

Stu Trevelyan, chief executive officer of DNC software vendor NGP VAN, acknowledged the breach in a statement and called it a "brief isolated issue" that was fixed and is now being reviewed.

According to his LinkedIn account, Trevelyan is a former campaign and White House staffer for Hillary Clinton's husband, former President Bill Clinton. He also donated $403.20 to Ready PAC - an outside group then known as Ready for Hillary PAC that supports Clinton - in December 2013, according to records filed with the Federal Election Commission.

Josh Uretsky, the Sanders campaign staffer fired for accessing the voter file, told MSNBC that his intent was to document and understand the scope of the problem so it could be reported.

"To my knowledge, we did not export any records or voter file data that were based on those scores,” he said.

Sanders supporters were outraged by the DNC's response to the breach.

"I think the DNC's crossed the line and it's going to open up a whole new part in the campaign season," said RoseAnn DeMoro, executive director of National Nurses United, a liberal group that endorsed Sanders. "I think this is a gloves-off moment."

(Additional reporting by Susan Heavey in Washington and and Luciana Lopez and Emily Flitter in New York; Writing by Steve Holland and John Whitesides; Editing by Bill Trott, Lisa Shumaker and Michael Perry)