CAPE TOWN, South Africa — There was a strange atmosphere at the edge of Africa. Cloudless skies and balmy spring breezes greeted the delegations of regional and business leaders who met last week for a major annual summit on the future of the continent. But they gathered in a city reeling from trauma.

After news emerged of the violent and murder of a student at the prestigious University of Cape Town, protesters massed at the gates of the convention center where the World Economic Forum was being held. Their ire over “gender-based” violence compounded the sense of tension smoldering elsewhere in the country, which has seen a resurgence of xenophobic attacks by local mobs on foreign migrants and shopkeepers.

South African President Cyril Ramaphosa had to break away from the forum’s proceedings to address the protesters’ concerns in a session of Parliament. But he returned the next day to extol the virtues of a potentially monumental African free-trade pact, stitched together over more than a year of diplomatic effort to little fanfare elsewhere in the world. The optimism of the World Economic Forum would not be dimmed by the unease outside its halls.

The deal is “going to be the greatest opportunity for economies on the continent to generate growth through trade,” Ramaphosa said.

On paper, that seems true. After Nigeria signed on to the African Continental Free Trade Area on the sidelines of the African Union summit in July, investors, wonks and politicians all started to dream of what may follow: a $3.4 trillion economic zone of some 1.3 billion people. In a report earlier this year, the International Monetary Fund dubbed the free-trade deal a “game changer” if African governments are able to bring down tariffs and boost trade within the continent.