ANTALYA, Turkey — When I was stuck at the airport in this city in southern Turkey, on Friday night, I had many things to worry about. A coup attempt had just begun and the country was in turmoil. My plane to Istanbul had almost flown into the worst of the fighting, but luckily we were prevented from taking off at the last minute when the airspace was closed.

One thing I did not have to worry about, though, was running out of data on my phone. In the early morning hours, Turkey’s leading cellphone provider topped up the internet allowance of every subscriber. This was more than unusual. Turkey has experienced many crises recently, including deadly terrorist attacks, and they usually lead to a closing of information flows, not the government-aligned service provider’s making it easier to transmit information.

The reason was simple: In the confusing hours after the coup attempt began, the country had heard from President Recep Tayyip Erdogan — and even learned that he was alive — when he called a television station via FaceTime, an easy-to-use video chat app. As the camera focused on the iPhone in the anchor’s hand, the president called on the people of Turkey to take to the streets and guard the airports. But this couldn’t happen by itself. People would need WhatsApp, Twitter and other tools on their phones to mobilize. The president also tweeted out the call to his more than eight million followers to resist the coup.

The effect was immediate. On my drive back into the city from the airport, I encountered throngs gathering in squares, waving Turkish flags. Everywhere, their screens flickered as they held their phones out, taking defiant selfies to share with their friends, inviting them to join the protests. Within hours, most of the soldiers backing the would-be coup had been overwhelmed. Despite Turkey’s deep political and social divisions, every opposition party, too, immediately came out against the coup. Most did so by posting statements on Twitter.