WASHINGTON—The U.S. intelligence community took the extraordinary step Friday of directly accusing the Russian government of trying to interfere in the coming U.S. elections by purposefully leaking emails hacked from the Democratic National Committee and other entities.

The intelligence agencies, in a joint statement, alleged the hacks were directed by the most senior officials in the Russian government.

“We...