The Environmental Protection Agency said Friday that it won't be paying states $1.2 billion in damages they incurred as a result of a 3 million gallon toxic wastewater spill that EPA caused in Colorado going on two years ago.

EPA said it checked with Justice Department attorneys and under the law it is not allowed to repay the states for the major Gold King Mine spill that sullied the waterways of three states in the summer of 2015.

The law "does not authorize federal agencies to pay claims resulting from government actions that are discretionary – that is, acts of a governmental nature or function and that involve the exercise of judgment," EPA said in a statement.

"The circumstances surrounding the Gold King Mine incident unfortunately do not meet the conditions necessary to pay claims," the agency said.

Federal attorneys said the EPA is protected under the legal principle of sovereign immunity, which prohibits legal claims being honored by the federal government.

"Because the agency was conducting a site investigation at the Gold King Mine under the Comprehensive Environmental Response, Compensation, and Liability Act, the agency's work is considered a 'discretionary function' under this law," EPA explained. "Therefore, the circumstances surrounding the Gold King Mine incident unfortunately do not meet the conditions necessary to pay claims."

The agency explained that those who had filed claims and whose claims have been denied can challenge Friday's decision in U.S. federal court within six months.

"The EPA has taken responsibility for the Gold King Mine incident, including providing financial support, continued water treatment and monitoring, developing and implementing a permanent remedial plan for the broader mining region, and research to improve our understanding of how contaminants move through complex river systems," the agency said.