A major donor to President Trump agreed to pay $10 million to the president’s then-personal attorney if he successfully helped obtain funding for a nuclear-power project, including a $5 billion loan from the U.S. government, according to people familiar with the matter.

The donor, Franklin L. Haney, gave the contract to Trump attorney Michael Cohen in early April to assist his efforts to complete a pair of unfinished nuclear reactors in Alabama, known as the Bellefonte Nuclear Power Plant, these people said.

Had...