The Office of Personnel Management (OPM) said that while investigating a separate hacking incident in June, it discovered a far bigger breach of personal data.
"OPM and the interagency incident response team have concluded with high confidence that sensitive information, including the Social Security numbers of 21.5 million individuals, was stolen from the background investigation databases," the agency said.
The data related to information submitted by applicants for government jobs, as well as information noted down by investigators carrying out background checks on applicants and their relatives.
Background investigation records can include employment, health, criminal and financial history among other types of information.
"There is no evidence that health, financial, payroll and retirement records of federal personnel or those who have applied for a Federal job were impacted by this incident," the OPM said.
But it added that anyone who applied for a government job and underwent a background investigation in the last 15 years was "highly likely" to have been impacted.
In June, the OPM said personal data of about 4.2 million current and former U.S. government workers' appeared to have been hacked, after initially detecting a "cyber-intrusion" in April.
The agency was working with the Department of Homeland Security and the Federal Bureau of Investigation to prevent "similar thefts" in the future, it said on Thursday.
Previous cyberattacks had been blamed -- although not directly by senior officials -- on hackers in China, and cybersecurity was on the agenda of high-level talks between the U.S. and China last month.
China has said that any accusations that it was behind the hack were "baseless."
©2015 Deutsche Presse-Agentur GmbH (Hamburg, Germany) Distributed by Tribune Content Agency, LLC.