When Najwa Elyazgi’s flight touched down in Turkey, she checked the news on her phone and was shocked to see that President Trump had announced an executive order temporarily banning people from seven countries — including her own, Libya — from entering the United States.

Trump said the measure, which also included a temporary ban on refugees, would make the United States safer by keeping radical Islamist terrorists out of the country. He said the country would not welcome the very enemies that our soldiers are fighting overseas.

To his supporters, it sent a powerful signal that border security would finally be tightened.

To Elyazgi, it raised the question: Would the United States no longer welcome the top students from overseas?

Ever since she was a little girl, she had wanted to go to college in the United States. She had worked so hard in school that she had the highest grade-point average in her major of economics and political science in the country that year, an achievement that guaranteed her a full scholarship. She had survived a dictatorship, a revolution and a civil war, and she had completed all but the last two semesters of an undergraduate degree in international relations at George Mason University.

Suddenly, it all hinged on her connecting flight to Dulles.

She was already late. After winter break at home in Tripoli, she had to cancel her flight back to the United States when her entry visa was not approved, as it always had been before, within three business days. After nearly two weeks waiting in London — she had to go to another country to apply for visas because the United States does not have an embassy in Libya — she got the visa and booked a flight via Istanbul for that afternoon.

While she was in the air, Trump signed the ban.

When she was stopped as others boarded in Istanbul, and asked to wait, she knew.

“I was destroyed,” she said. “My whole future …”

In shock, she checked into a hotel near the airport, tried to reassure her parents, contacted her academic adviser and got in touch with a lawyer, Kevin George, who had volunteered to help Libyans affected by the ban. She went from tears to anger to forced composure, telling herself she couldn’t solve anything unless she stayed positive. And she kept checking the news, which was changing quickly, with lawsuits and injunctions.

After two days in her hotel room, she realized she was hungry and ordered some food.

After four days, a hotel employee knocked on the door and asked if she was all right; he saw the sign on her door requesting privacy hadn’t been removed, and they hadn’t seen her leave the room in that time.

“I was kind of like dead,” she said. “I was not really alive that week.”

One day, she woke up at 6 a.m., checked the news, read that visas would be considered suspended for anyone from the seven countries who was outside the U.S., drew the blinds and went back to sleep for the entire day.

But most of the time, she was frantically trying to find a solution. She was one of 82 students at George Mason from one of the seven countries, but the only one who was not in the U.S. when the executive order was signed. She knew that people from the attorney general of Virginia to the president of George Mason were trying to help. Her lawyer said he knew she was lonely and dejected, but he kept urging her not to leave Istanbul.

On Friday, he told her to book a flight to Boston on Lufthansa; some travelers were getting in.

She rushed to book a ticket — $3,800, which one of her brothers, who is a medical resident in the United States, told her he would help her pay for. But by the time she finished entering information, the last seat had been sold.

It was nearly 4 a.m. in Istanbul, and she wanted to scream. But she said to her brother an Arabic saying that she roughly translated as, “There is no good in doing that, so God took that away from you — it’s better not doing that.”

She thought, “I will just leave,” and go home to Libya. She turned out the light and tried to go to sleep.

When she was in elementary school in Libya, Elyazgi told people she wanted to go to college in the United States, which she believed offered the best education in the world. She wanted to study international relations and return to Libya to make her country better, safer, less isolated.

Her family opposed the Moammar Gaddafi regime, and she said they lived uneasily at times under the unpredictable rules of the dictatorship. They weren’t allowed passports, their car might be stopped for questioning, or a knock would sound at the door and her father would be escorted somewhere. She said close family members were imprisoned and killed.

Education was important to her family, but as she was finishing high school in 2011, civil war erupted. She fled with her mother and siblings to Tunisia for safety, and after Gaddafi was overthrown and violence subsided she began to try to resume her education. With chaotic conditions, though, it was not until 2013 that she learned that the scholarship she had been awarded, covering the cost of any university she chose, would be honored, and she began the slow process of gaining approval to study in the United States on a student visa.

She had not taken all the standardized tests needed for applications to the most prestigious universities, but she found that George Mason did not require them and would allow her to apply long after the traditional deadline.

She enjoyed her studies there, earned a 3.98 grade point average, and planned to apply to universities such as Harvard and Yale for graduate school — which is also covered by her scholarship — before returning to Libya permanently.

In the hotel in Istanbul, she thought it had all been wiped out with a single order.

“I would be expecting this from Libya,” she said. “We had it in different ways through all my childhood. … But I did not expect this from the United States — the number one place in the world, very liberal, with freedom of speech, freedom of religion, freedom, freedom, freedom.”

Her cellphone rang not 10 minutes after she had given up in Istanbul. It was her brother again.

She asked George, who told her: Get on the next flight.

In the United States, Trump warned on social media that the judge had made the country less safe by hindering his executive order.

Spokesmen for the Department of Homeland Security and the White House did not immediately respond to requests for comment.

Elyazgi called the airline, which said seats were available but she must buy them at the airport. She took a shower, her first in a week, grabbed her bags and rushed to the airport, where she asked security officials if she would be allowed to board a flight. One said no, but when she asked a supervisor and was told yes, she ran, lugging her bags, to the airline ticket counter.

Even seated on the plane, she was nervous. For 45 minutes the plane did not move, she said, and no announcement was made; she expected any minute that someone would walk to her seat and tell her she had to get off the airplane.

The plane took off. Her heart lifted.

She was still nervous, unable to sleep as she normally would on a 12-hour flight, knowing she might be detained at the airport in Virginia. “But inside me I knew, if I got to the United States, the Constitution will protect me.”

She expected many extra layers of security at the airport.

The agent, she said, only asked her one question.

When she answered that she was a student at George Mason, he stamped her passport and said, ” ‘Welcome back. We missed you.’ ”

When she saw all protesters — many of them white Americans, she said, people who didn’t seem to be directly impacted by the executive order — joining the lawyers and politicians and reporters and family members in a crowd at the airport, she had to blink away tears in her eyes.

“I felt alive again,” she said Monday. She had just talked with the president of George Mason and others on campus, and been assured that she could resume the semester — with 20 credits’ worth of classes, far more than the typical 12-15-credit load — despite missing so many days. “She’s an extraordinary student, ” said Rose Pascarell, vice president for university life. “We’re delighted that she’s back.”

Elyazgi was back in the classroom Tuesday. “I felt loved,” she said.

“Before I didn’t feel the United States is my home; it’s not. It’s a place I go to school, and when I am done, I will leave.” Seeing all the people protesting the immigration order, she said, “Now I feel these people love me, as if this is my home.”