Acting assistant attorney general Mary McCord announced that the four people had been indicted at a news conference in Washington DC.
The FSB agents were identified as Dmitry Dokuchaev and Igor Sushchin.
Ms McCord said they had "protected, directed, facilitated and paid criminal hackers to collect information through computer intrusions in the United States and elsewhere".
They are accused of hiring Alexsey Belan and Karim Baratov to carry out the attacks.
Ms McCord said the targets of the hack included security, diplomatic, journalists and military personnel and the cyberattack was used for espionage and financial gain.
Officials revealed the Yahoo hack began as early as 2014 and even though the hackers lost access last September, they continued to use the information acquired until as late as December 2016.
It is the first criminal case brought in the US against Russian government officials.
Details of 500 million users were stolen during the hack - one of the largest in history.
Ms McCord added that one of the hackers, Alexsey Belan, had been on the FBI's most wanted list for three years.
She clarified that the indictment doesn't allege any connection between the the Yahoo hacking and the attack on the Democratic National Convention.