As Portuguese lender Banco Espírito Santo SA neared collapse this summer, it found a Wall Street ally to help it raise funds: Goldman Sachs Group Inc.

Through a Luxembourg financing vehicle created by Goldman, Banco Espírito Santo received $835 million in July, according to a prospectus reviewed by The Wall Street Journal, a time when it was nearly impossible for the troubled lender to borrow directly in the capital markets.