When it became clear that a majority of the doctors were losing in court, the WhatsApp group became a place for doctors to strategize and commiserate.

“We keep one another strong,” said Dr. Jiménez, who says she has been unemployed since being fired in June and is now barred from re-entering Cuba for eight years.

Dr. Álvarez and her husband were among the lucky ones to keep their jobs and get what amounted to a huge pay raise. They also managed to bring their children to Brazil.

“It’s sad to leave your family and friends and your homeland,” she said. “But here we’re in a country where you’re free, where no one asks you where you’re going, or tells you what you have to do. In Cuba, your life is dictated by the government.”

Mr. Barros, the Brazilian health minister, said the Cuban doctors should not feel as if they were being poorly compensated, because their salaries were similar to what Brazilian doctors earned during their residencies.

“None of them, to this day, has come to me to complain about their work conditions,” he said.

Mr. de Santana, the lawyer, says he hopes Brazil’s Supreme Federal Court will take up the case. But because Brazil’s top court is so backlogged, a definitive ruling may take years.