ROME — As she guided a ship carrying 40 rescued, increasingly desperate migrants into port on the island of Lampedusa, Capt. Carola Rackete did not fully realize that she had become one of Italy’s most polarizing figures over the previous two weeks.

By docking after being told she should not, she had firmly landed in the sights of Italy’s powerful, nationalist interior minister, who described the event as an “act of war.” And then she was immediately arrested by the police.

But Captain Rackete, 31, said she had been thinking about her passengers. “I was concerned for safety of the people who we had rescued,” she said in a telephone interview Friday. “That was always the first priority in all the decisions that we made.”

Because she could not guarantee their safety, she added, “I decided to bring them to shore.” The captain has since been freed by a judge, though prosecutors are still investigating.