In addition to the ban, which takes effect on Monday, there will be heightened restrictions on visitors from seven other countries.
Some but not all of the 12 countries banned in the new proclamation also appeared on the list of banned countries in Trump's first term.
Trump issued an executive order in January 2017 banning travel to the U.S. by citizens of seven predominantly Muslim countries — Iraq, Syria, Iran, Sudan, Libya, Somalia and Yemen.
The ban was retooled amid legal challenges until a version was upheld by the Supreme Court in 2018. Trump appears to be on firmer ground with the bans this time after the Supreme Court sided with him.
In a video released on social media explaining the travel restrictions, Trump tied them to the recent attack in Boulder, Colorado, in which police say an Egyptian man injured a dozen people assembled to raise attention for Israeli hostages in Gaza.
Trump said the attack underscored the dangers posed by some foreign nationals and visitors who overstay visas. Federal authorities have said the Boulder attack suspect has been living in the U.S. illegally. Egypt is not on Trump's restricted list.
Trump said the severity of the restrictions on each country depended on how strong the threat was. He said the list could be updated to reflect improvements or additional threats around the world.
People from a dozen countries will be banned from entering the United States under Trump's ban. Those countries include Afghanistan, Myanmar, Chad, the Republic of Congo, Equatorial Guinea, Eritrea, Haiti, Iran, Libya, Somalia, Sudan and Yemen.
There will also be heightened restrictions on visitors from Burundi, Cuba, Laos, Sierra Leone, Togo, Turkmenistan and Venezuela.
"I must act to protect the national security and national interest of the United States and its people," Trump said in his proclamation.
Ten of the 19 countries under the bans and restrictions are in Africa, nine of those from majority-Black African countries. Several of those, including Sierra Leone, Togo and Equatorial Guinea, are not known for hosting armed groups that pose a major threat to the West.