Fidel Castro looked frail but alert and even playful in a series of official photographs taken during a meeting with Brazil's president on Tuesday, the first images of the ailing Cuban leader released in about three months.

Wearing a tracksuit and tennis shoes that have become his trademark since he fell ill, Castro is seen seated and grinning, his beard well-trimmed and his hair combed as he talks with President Luiz Inacio Lula da Silva. In some images, he is seen pretending to snap pictures with a small camera.

Taken in an undisclosed location, the photographs were given to reporters as Silva left Cuba, concluding a 24-hour visit. They were the first photos of Castro since October, when he met with his good friend and socialist ally, Venezuelan President Hugo Chavez.

Silva said he and Castro met for two and a half hours and "conversed about all topics."

"He has incredible lucidity and impeccable health," the Brazilian president said. "He's as lucid as in his best moments."

Lula said politicians were like athletes, possessing a need to stay active. He said he felt Castro "would soon take on a political role in Cuba" and while he provided no specifics, he may have been hinting that the 81-year-old could remain as head of Cuba's supreme governing body, the Council of State, rather than prematurely retiring.

Castro has not been seen in public since emergency intestinal surgery forced him to cede power to a provisional government headed by his younger brother Raul in July 2006. But he remains head of the council and is running in parliamentary elections Sunday, a necessary step if he is to hold on to Cuba's top post.

His condition and exact ailment are state secrets, though he has met behind closed doors several times with Chavez and released essays on an array of topics that appear in state-run media. Castro has also met with Bolivian President Evo Morales, Nicaraguan leader Daniel Ortega and officials from China, Vietnam and Angola.

Tuesday's meeting was a surprise ending to a visit during which Lula, a leftist and friend of Castro, offered the communist government millions of dollars in credit and signed a deal to drill for oil in the Gulf of Mexico.

It had been unclear whether Silva would see Castro in person right up until the meeting actually began. Brazilian officials had said it was up to the Cuban leader's doctors to determine if he was well enough.

Earlier, Silva signed accords extending Cuba credits that strengthened ties between Latin America's largest economy and the government of Raul Castro, despite Washington's nearly 50-year-old trade embargo against the island. He also signed a deal for Brazil's state energy company, Petrobras, to drill for oil in the Gulf of Mexico.

The credits will provide favorable Brazilian financing for construction projects and pharmaceutical and agricultural initiatives and show that Silva's visit wasn't simply a chance for him to check on Castro, said Phil Peters, a Cuba analyst with the Lexington Institute, a think tank near Washington D.C.

"Lula decided this is not going to be a farewell visit to Fidel. It's a vote of confidence to Raul," Peters said. "Brazil is going out of its way not just to make a visit that conveys political support, but to put substantial economic resources on the table."

Foreign Ministry officials in Brasilia suggested that food credits alone would total US$100 million, although the agreements themselves did not specify how much financing Brazil will provide.

Silva traveled with four Cabinet ministers and Petrobras chief Jose Sergio Gabrielli, who formalized plans for exploratory deep-water drilling for crude oil off Cuba's coast and for a lubricant factory on the island.

Cuban Gulf waters could contain large quantities of crude, and Spanish, Canadian, Indian and Malaysian companies have already signed contracts to explore the area. The U.S. trade embargo prohibits U.S. companies from investing in the area.

Tuesday's accords were another blow to U.S. efforts to isolate Cuba with trade sanctions, Peters said.

"It's the latest sign that the rest of the world completely disagrees with the U.S approach to Cuba," he said.