Hillary Clinton's campaign aides last year used the Keystone oil pipeline project to try to divert attention away from her use of private email while serving as secretary of state, according to emails released by WikiLeaks.

The Canada-U.S. pipeline project, finally rejected by President Barack Obama's administration in November 2015, had crystallized the debate over energy and the environment in the United States.

It was fiercely opposed by Bernie Sanders, Clinton's rival in the Democratic primary elections to pick the party's presidential nominee.

In August 2015, several months before the Obama administration announced its decision, Clinton's advisers wondered how to reveal her opposition to the Keystone project, the emails show. Until then she had made no public stance.

"We are trying to find a good way to leak her opposition to the pipeline without her having to actually say it and give up her principled stand about not second-guessing the president in public," wrote speechwriter Dan Schwerin.

Clinton's campaign manager Robby Mook came up with a different solution: publicly state her opposition. That "will solicit criticism... but that might help distract from emails," he said, according to the leaked messages.

The controversy over Clinton's use of a private email server while she was the Obama administration's top diplomat was in full swing at the time, forcing her to publicly apologize for its use in September.

The idea of publishing an op-ed article stating her opposition to Keystone was also discussed.

"Given that we just offered an apology on emails that some reporters think happened 'on a dime' after months of resistance, do we worry that publishing an oped... will be greeted cynically and perhaps as part of some manufactured attempt to project sincerity?," wrote campaign spokesman Brian Fallon.

Clinton eventually announced her opposition to Keystone at a campaign rally in late September 2015.

The emails recently released by WikiLeaks also reveal Clinton was wary of supporting a bill to separate commercial and investment banks, a financial reform championed by Sanders and the left wing of the Democratic Party.

"I understand that we face phoniness charges if we 'change' our position" by supporting the law, wrote campaign aide Mandy Grunwald. "But we face political risks this way, too."

Clinton ended up refusing to support such a law.

In other documents recently released by WikiLeaks, Clinton, in private speeches to major banks in 2013 and 2014, expressed views in favor of free trade and Wall Street self-regulation that are at odds with her positions as a candidate.

Clinton won the Democratic presidential nomination in July of this year.

Her campaign has accused anti-secrecy website WikiLeaks of releasing documents to help Republican rival Donald Trump in the race for the White House.

jt/vs/dw