Not long ago, Sarah and Yusra Mardini were hailed as heroes, Syrian refugees and competitive swimmers credited with saving lives on a perilous sea voyage to Europe by slipping into the water and pushing their foundering boat toward shore. Later, they dedicated themselves to helping other migrants, and Yusra Mardini went on to swim at the Olympics.

Now Sarah Mardini and at least four other members of a migrant aid group are in Greek jails, facing charges including espionage, violation of state secrecy laws and criminal enterprise — offenses that could keep them locked up for decades.

The group “was active in the systematic facilitation of illegal entrance of foreigners,” the Greek police said in a statement after the initial arrests, and violated the country’s Migration Code — the same charge used against those paid to smuggle people.

Their defenders insist that the group did nothing but gather information, and use it to save people from drowning and to provide them with humanitarian aid. The government, they say, is trying to criminalize these acts.

Last week, the founder of the group, Panos G. Moraitis, said in an interview with Lesvosnews.gr, a news site, that some of its members were in “detention under surreal charges, especially if one considers how closely we have been cooperating with the authorities.”

Then he, too, was arrested.

The case reflects how much has changed since the summer of 2015, when the Mardini sisters arrived in an immense wave of refugees and economic migrants to Europe, mostly from the Middle East and Africa. On the beaches of Greece, many local residents turned out to provide food, blankets and shelter. Germany adopted an open-door policy, eventually taking in more than a million migrants.

“Things have taken a quick, abrupt turn to the worse, without any obvious reason,” said Vasilis Spirou, Mr. Moraitis’s lawyer.

The Mardini sisters fled the civil war in Syria, made their way across Turkey and were herded by smugglers onto a flimsy boat to cross a few miles of Aegean waters to reach the Greek islands. Hundreds of thousands of people made similar crossings — and thousands died trying — but the sisters’ story had an extraordinary twist.

As night fell, their overloaded dinghy began filling with water and its motor failed; most of the 20 people aboard did not know how to swim. So Sarah, then 20, and Yusra, 17, and two men went into the sea and swam, for hours, in the dark, the sisters said, pushing the boat to the island of Lesbos.

Months later, after they settled in Germany, their tale drew worldwide attention when Yusra was selected for the first-ever refugee Olympic team, to compete in the 2016 games in Rio de Janeiro. She wrote a book about her experiences, which is being made into a film, and became a “good-will ambassador” for the Office of the United Nations High Commissioner for Refugees.

Around the same time the Mardinis left Syria, Mr. Moraitis, the chief executive of a maritime security business, founded Emergency Response Center International, one of hundreds of organizations that responded to the migration crisis. When migrants are at risk of drowning, the group sends boats to rescue them, and it provides services to those who reach Greece.

Sarah Mardini — whose sister wrote of her, “no one can get her to stay quiet” — began volunteering with the group in 2016.

In late August, she was arrested as she waited to catch a flight back to Germany, where she was enrolled at Bard College Berlin. Also arrested around the same time were two Greek citizens who work for the group, Nassos Karakitsos and Mirella Alexou, and a German volunteer for it, Sean Binder.

Weeks passed before the authorities acknowledged holding any of them, though their detention had been widely reported, based on the accounts of friends and co-workers. Under Greek law, they can be held for up to 18 months before trial.

In their only official statement on the case, made almost a month ago, the police said that in all, six Greeks and 24 foreigners were complicit, though it was not clear how many would be charged. Prosecutors declined to comment.

The two sides agree that the group used radios, telescopes, WhatsApp message groups and simple observation to gather and share detailed information on the movements of migrants in Turkey and on the sea, including the geographic coordinates of specific boats, the number of people aboard, and where and when they were expected to arrive.

The police said the group had withheld much of that information from the Coast Guard and other authorities, which it denies.

The police say that through its actions, the group effectively “gave direct assistance to organized refugee trafficking rings” and committed “the illegal interception of radio communications” from the Greek Coast Guard and other authorities. Group representatives say the messages were on publicly accessible channels.

The police said the motive of the group, which runs on donors’ contributions, was to profit from illegal deeds, making it a criminal enterprise.

But in his interview last week, Mr. Moraitis said the group’s actions were both legal and selfless. Its original aim, and still its core purpose, he said, was “to help and rescue human life in the sea.”

A version of this article appears in print on , on Page A10 of the New York edition with the headline: They Were Hailed as Heroes. Now One Sister Is in Jail.. Order Reprints | Today’s Paper | Subscribe