U.S. President Barack Obama ordered Friday an end to the electronic surveillance of leaders of allied nations and changes to the way the National Security Agency accesses data about hundreds of millions of telephone calls.

"The reforms I'm proposing today should give the American people greater confidence that their rights are being protected, even as our intelligence and law enforcement agencies maintain the tools they need to keep us safe," he said in a speech at the Justice Department.

The president defended the way the intelligence complex works both at home and abroad, though he admitted the need to consider the privacy concerns sparked by the disclosure of top-secret documents by former NSA contractor Edward Snowden and take the appropriate measures.

The documents also revealed surveillance targeting the personal communications of leaders of friendly governments, including German Chancellor Angela Merkel and Brazilian President Dilma Rousseff.

"I have made clear to the intelligence community that - unless there is a compelling national security purpose - we will not monitor the communications of heads of state and government of our close friends and allies," Obama said Friday.

As for the NSA collecting the phone records of tens of millions of Americans, Obama ordered the transition to a new mechanism "that preserves the capabilities we need without the government holding this bulk metadata." EFE