Cuba has said it is ending a program that sent thousands of government doctors to under-served regions of Brazil after a deterioration in relations between the countries following the election of far-right candidate Jair Bolsonaro.
Cuba made the announcement after Mr Bolsonaro said the "Mas Medicos" program overseen by the World Health Organisation could only continue if doctors directly received their salaries from Brazil, and were able to bring their families with them during their assignments, among other conditions.
The Cuban government generally keeps most of the salaries of state employees working abroad as part of the socialist state's "international missions." The program brings in hundreds of millions in badly needed hard currency for the government.
Participants also are generally barred from bringing family members in a measure that critics say is designed to prevent doctors from emigrating.
"Mas Medicos" started five years ago under Dilma Rousseff, the leftist former Brazilian President. Cuba said roughly 20,000 doctors saw millions of patients in areas such as the Amazon rainforest and slums of major cities.
Cuba maintains similar missions in 67 other countries but "Mas Medicos" was one of the largest and most important, serving as a link between the cash-strapped island and South America's largest economy.
"Cubans have provided a valuable service to the Brazilian people with dignity, deep sensitivity, professionality, dedication and altruism," Cuban President Miguel Diaz-Canel wrote on Twitter. "Such humane acts should be respected and defended."
All Cuban doctors work for the state and virtually all receive salaries that are well below $100 a month. Doctors are not permitted to leave Cuba without government permission, a control that was lifted for virtually all other Cubans five years ago.
Thousands of Cuban doctors work in the island's public health-care system, which suffers from crumbling infrastructure but still provides free and universal health care to all citizens.
Thousands of other Cuban doctors go abroad each year and generate billions of dollars for the state, one of Cuba's most important sources of foreign exchange.
The doctors generally receive a fraction of the salary paid to the Cuban government. But even that fraction far exceeds the salaries of doctors working in Cuba. That drives many doctors to complete foreign missions in order to earn cash for important expenses like home repairs, appliances or a motor vehicle.
The Brazilian Ministry of Health said there were 8,332 Cuban doctors in Brazil, each costing the country roughly $3,100 a month, plus room and board.
Mr Bolsonaro said Brazil would offer asylum to Cuban doctors who wished to stay in Brazil.
"This is slave labour," he said. "I couldn't be an accomplice of that."
Neither side said exactly when the Cuban doctors would be leaving but their departure comes at a bad time for Cuba, which is facing its third year of slow growth, expected to be around 1 percent this year.
Productivity is low in virtually every state-run industry, tourism has slowed under the Trump administration and Venezuela, a key ally, has cut back on subsidized oil and other aid.
Nonetheless, Bolsonaro's conditions were out of the question for Cuba.
"It's not acceptable to question the dignity, professionalism and altruism of Cubans who, with the support of their families, provide services in 67 countries," the Cuban health ministry said in a statement.
"The Brazilian people will understand who bears the responsibility for the fact that our doctors can't keep providing their support and solidarity in that nation."