Justice secretary says thousands of prisoners will be released early 'to avert disaster'