Calling it "decaying and rotten", he said the deal was "an embarrassment" to him "as a citizen".
He said he would reimpose economic sanctions that were waived when the deal was signed in 2015.
The move goes against advice from his European allies and some military advisers.
But Israel's Prime Minister Benjamin Netanyahu says he "fully supports" the "bold" withdrawal.
The so-called Joint Comprehensive Plan of Action (JCPOA) saw Iran agree to limit the size of its stockpile of enriched uranium - which is used to make reactor fuel, but also nuclear weapons - for 15 years and the number of centrifuges installed to enrich uranium for 10 years.
Iran also agreed to modify a heavy water facility so it could not produce plutonium suitable for a bomb.
In return, sanctions imposed by the UN, US and EU that had crippled Iran's economy were lifted.
The deal was agreed between Iran and the five permanent members of the UN Security Council - the US, UK, France, China and Russia - plus Germany.
Iran insists its nuclear programme is entirely peaceful, and its compliance with the deal has been verified by the International Atomic Energy Agency (IAEA).