We prove a law of large numbers for the loss from default and use it for approximating the distribution of the loss from default in large, potentially heterogenous portfolios. The density of the limiting measure is shown to solve a non-linear SPDE, and the moments of the limiting measure are shown to satisfy an infinite system of SDEs. The solution to this system leads to %the solution to the SPDE through an inverse moment problem, and to the distribution of the limiting portfolio loss, which we propose as an approximation to the loss distribution for a large portfolio. Numerical tests illustrate the accuracy of the approximation, and highlight its computational advantages over a direct Monte Carlo simulation of the original stochastic system.