NEW YORK (Reuters) - Moody's Corp has agreed to pay nearly $864 million to settle with U.S. federal and state authorities over its ratings of risky mortgage securities in the run-up to the 2008 financial crisis, the U.S. Department of Justice said on Friday.