President Obama and Cuban President Raúl Castro will hold a bilateral meeting Saturday on the margins of the Summit of the Americas here, the first such encounter between leaders of the two nations in more than 50 years, White House officials said.

Planning for an Obama-Castro meeting has been a slow diplomatic choreography since December, when the two leaders announced that Cuba and the United States would restore diplomatic relations, including three rounds of lower-level negotiations over the mechanics of normalization.

The leaders’ meeting will occur on the margins of Saturday’s formal summit gatherings, when “we anticipate they will have a discussion,” deputy national security adviser Benjamin Rhodes said.

In a symbolic icebreaker, the two “greeted each other and shook hands” at the beginning of the summit’s opening session and dinner Friday night, National Security Council spokeswoman Bernadette Meehan said. A White House official said it “was an informal interaction and there was not a substantive conversation.” They have met face to face only once before — a handshake at Nelson Mandela’s funeral in South Africa.

Confirmation of a Saturday meeting came as the Cuban delegation to a gathering of civil society leaders said it would not attend meetings being held here as part of the summit because of the presence of “terrorist individuals” and “mercenaries” it said were in the pay of unnamed ­foreign powers.

The apparent reference was to members of the Cuban diaspora in the United States who have long been accused of anti-Castro acts, some of whom have been outspoken in opposition to U.S.-Cuba rapprochement.

The announcement of the Obama-Castro meeting and extensive Cuban outreach to foreign business leaders, including Americans, has contrasted sharply with the denunciations of ­Cuban Americans and Cuban support for anti-U.S. leaders such as Venezuelan President Nicolás Maduro.

And the competing impulses illustrate the narrow line Havana is walking as it moves closer to the United States while trying to retain its control at home and its self-proclaimed revolutionary image.

Obama and Castro spoke by telephone this week as both prepared to leave their capitals for the 35-nation hemispheric gathering. On Thursday evening, Secretary of State John F. Kerry met here for more than two hours with Cuban Foreign Minister Bruno Rodríguez, another historic first.

Obama’s standing in the Western Hemisphere has been enhanced by the highly popular Cuba agreement. The last two Americas summits, in 2009 in Trinidad and Tobago and in 2012 in Cartagena, Colombia, ended on sour notes over U.S. insistence that Cuba continue to be excluded from the gathering.

Although full normalization of relations — including the lifting of congressionally mandated U.S. economic sanctions — will be gradual and may be years away, reestablishment of diplomatic relations, severed by the United States in 1961, can be quickly done by the two presidents.

The main roadblock has been Cuba’s refusal to do so until the United States removes Cuba from the list of state sponsors of terrorism. After a months-long review, the State Department recommended to Obama this week that he do so.

An announcement could come as early as Saturday, but Obama’s approval would launch a 45-day waiting period before the list removal would take effect. U.S. officials believe the Cubans may be reluctant to move forward with the reopening of embassies before the measure becomes official. Congress could use the enforced waiting period to introduce legislation attempting to block the action, although such a move is seen as highly unlikely.

Traveling by helicopter above traffic and delegate-clogged streets Friday, Obama visited the Panama Canal, walking across the historic Miraflores Locks with his suit jacket slung over his shoulder.

At a session with international business leaders, Obama participated in a panel that included the leaders of Mexico, Brazil and Panama as well as Facebook chief executive Mark Zuckerberg. Obama noted that Latin America’s exports to the United States have grown more than 50 percent since 2009, when he took office.

His comments made no explicit reference to Cuba or Venezuela, but he appeared to make an indirect reference to the two countries in remarks about changes in the region.

“One of the advantages that we may have today that we didn’t have, let’s say, 15 or 20 or 30 years ago, is, I think, it used to be viewed as either you have a government or state economic model, or you have a complete free market, and everything was very ideological sometimes in this region in discussing how economic development went forward,” he said.

“And I think, by virtue of wisdom and some things that didn’t work and some things that did, everybody around the region, throughout the hemisphere, I think has a very practical solution — or a practical orientation,” he said, adding, “Maybe not everybody, but almost everybody,” drawing laughter and applause from an audience heavy with corporate executives.

The president also touted his $1 billion aid initiative for Central America and praised Mexican President Enrique Peña Nieto’s controversial overhaul of the oil sector. “That’s a very sensitive thing and very difficult thing,” Obama said.

Later, Obama addressed a forum for civil society leaders, where his biggest applause line came at the beginning. Noting that it was the first time civil society had been included at one of the summits, he said he was also “pleased to have Cuba represented with us for the very first time.”

The presence of the civil society groups — including pro- and anti-Castro Cuban groups — has given Panama City something of a circus — but also ugly — atmosphere. The two sides clashed Wednesday when pro-Castro crowds blocked Cuban dissidents from participating at an outdoor gathering.

Friday’s online version of Granma, Cuba’s Communist Party newspaper, published a declaration from the country’s official civil society delegation saying that it refused to attend the summit’s meetings.

“Particularly offensive,” the statement said, “is the presence of terrorist-related individuals such as Luis Posada Carilles and Felíx Rodríguez Mendigutia,” whom the delegation said it had identified with “documentary proof.” Havana holds Posada responsible for a series of deadly anti-Castro bombings in the 1970s. Former CIA agent Rodríguez is the man credited with hunting down revolutionary icon Ernesto “Che” Guevara in 1967 and overseeing his execution. There has been no sign of either man at public events where Cubans were present.

U.S. relations with Venezuela have also been a sideshow at the summit. Maduro, with signed citizen petitions in hand, has demanded that the Obama administration repeal sanctions imposed against seven officials in his government for corruption and human rights abuses.

Maduro, who arrived at the summit Friday morning, traveled directly from the airport to a “people’s” summit gathering in the Panama City neighborhood of El Chorrillo, where a crowd of several hundred had gathered around a monument to those who died during the 1989 U.S. invasion of Panama that drove then-President Manuel Noriega from power.

But as Maduro arrived Friday night at the conference center, scores of windows were thrown open in surrounding high-rises. In a coordinated protest, anti-
Maduro Venezuelans banged pots and pans, shouted curses and blinked their lights on and off.