Almost immediately after the Manhattan terrorist attack on Tuesday, President Trump faulted the “diversity lottery” visa program under which the Uzbek immigrant suspected in the attack entered this country, and laid the blame for the program’s existence on Senator Charles Schumer and other Democrats.

As is often the case, he is wrong on his facts — here, about political responsibility for the program, which has been supported by both parties for over 25 years (though Mr. Schumer has backed getting rid of it). But Mr. Trump is right that these visas are bad policy and that the program should be canceled. Better still, they should be used for other, wiser purposes.

First, the facts. Of the roughly one million permanent resident visas — commonly known as green cards — issued each year, 50,000 are awarded through a lottery process with few preconditions other than that applicants come from countries with little immigration to the United States during the previous five years.

Congress made this program permanent in 1990 after several years of experimentation. Senator Edward Kennedy of Massachusetts and Representative Bruce Morrison of Connecticut, both Democrats, invoked a “diversity” rationale in noting that the program would help the many Irish in the United States who had overstayed their temporary visas. Despite the numerous people of Irish background already in the country from earlier waves of migration, Ireland was an eligible country under the program because, at the time, its economy was doing well and few people were emigrating. So much for actual diversity.