Among the planned sites for Mr. Ai’s project are Flushing Meadows-Corona Park in Queens, the Cooper Union building in Manhattan and Doris C. Freedman Plaza, at the tourist-heavy southeast corner of Central Park.

The title is a reference to Robert Frost’s poem “Mending Wall,” which uses the line “Good fences make good neighbors” as a mysterious refrain. Mr. Ai, who lived in New York during the 1980s, said in an email that this work is a reaction to “a retreat from the essential attitude of openness” in American politics.

“When the Berlin Wall fell, there were 11 countries with border fences and walls,” Mr. Ai said. “By 2016, that number had increased to 70. We are witnessing a rise in nationalism, an increase in the closure of borders, and an exclusionary attitude towards migrants and refugees, the victims of war and the casualties of globalization.”

Other recent artwork by Mr. Ai has similarly dealt with heated current events, such as the exhibition “Laundromat,” which included thousands of castoff items from a refugee camp, at Deitch Projects last fall. And in June, “Hansel & Gretel,” a surveillance-themed installation created with the architects Jacques Herzog and Pierre de Meuron, will open at the Park Avenue Armory.

“Ai Weiwei pours his heart and soul into art that asks big questions and is not constrained by artistic and social traditions,” Chirlane McCray, the first lady of New York, said in a statement. With “Good Fences Make Good Neighbors,” she added, “he challenges us to think about the function and rationale for a common barrier. Given that the immigrant experience is at the core of what binds us as New Yorkers, the exhibition compels us to question the rhetoric and policies that seek to divide us.”