Forced at gunpoint to read a statement by coup plotters and raided by rebel military forces, Turkey's media organisations were bruised by the drama of a coup but also played a role in ensuring it did not succeed.
A presenter with state-run TRT television had to read a statement late Friday from a group called "the Council for Peace in the Homeland," which claimed to have superseded the regular Turkish armed forces and to have taken control in the country.
Another private channel was raided by rebel soldiers and forced to temporarily cut its broadcasts.
But television channels also played a role in facing down the coup, broadcasting messages from President Recep Tayyip Erdogan urging his supporters to go out on to the streets and providing sometimes impressive coverage of the events as they unfolded.
"I read the statement (of coup plotters) under gun threat," TRT's female anchor Tijen Karas said, recounting her ordeal while she was live on state television.
"They tied our hands from behind and told us not to ask any questions. They took us to a closed room except for three or five people who were to make the broadcast," she said in televised remarks.
"They ordered us to read the statement after taking us out of the locked room... You must have realised the fear in my eyes and my lips were trembling. These were hours that loomed over like a nightmare."
Hours after the TRT broadcast, a group of armed soldiers stormed the Istanbul premises of one of Turkey's largest media conglomerates, Dogan Media Group, which owns the CNN Turk channel as well as the Hurriyet daily and its English-language sister paper Hurriyet Daily News.
CNN Turk was forced to stop its live broadcast.
- 'Never forget this night' -
It was CNN Turk which communicated Erdogan's first messages to the public as TRT was raided by rebel soldiers. Erdogan, who joined the private television via a smart phone, urged people to take to streets in a show of protest against the coup attempt.
Subsequently, their studios were raided by the rebel soldiers.
CNN's woman anchor Basak Sengul, who appeared calm and professional, said: "I heard their voices, they entered the building, and I also heard they spoke with our colleagues to stop the broadcast."
The television for a while showed an empty screen, punctuated from time to time with the sound of gunfire and brawls.
Hurriyet editor-in-chief Sedat Ergin said at the time: "At this moment we cannot print our newspaper."
He later said: "There are bullet marks in the walls of the building. Maybe it's better to keep them not to forget the night of July 15."
There were similar scenes at the headquarters of digital and cable TV provider Digiturk.
Pro-government Yeni Safak photographer Mustafa Cambaz was gunned down by rebel soldiers after calling for protests on social media against the coup attempt.
- 'Stop treating journalists as traitors' -
Erdogan has often came under fire for cracking down on dissenting journalists and Turkey's press freedom record has deteriorated under his 13-year rule as prime minister and then president.
Media rights activists said the authorities should take note and treat media with more respect after their role in the drama.
"Like the rest of Turkish society, the leading news media demonstrated their commitment to democratic principles during the past night," Reporters Without Borders secretary general Christophe Deloire said.
"It is time for the authorities to take note and to stop treating critical journalists as traitors and terrorists. Reinforcing national cohesion requires respect for basic freedoms including media freedom."
Erdogan, who is himself critical of social networks and once threatened to "wipe out" Twitter, used social media to communicate his appeal to people for resistance and remain on the streets.
Some journalists were also physically attacked by furious opponents of the coup.
A video showed CNN Turk reporter in Ankara, Kenan Sener, fleeing from a furious crowd of people -- apparently government supporters suspicious of secular media outlets.
Prime Minister Binali Yildirim on Saturday congratulated the media for showing "patriotism" and taking side in favour of the people, while apologising for the incidents.
Emre Kizilkaya, Hurriyet's digital content coordinator, tweeted: "The putsch was not only televised, but also tweeted and broadcast live on Facebook, while putschists could manage to censor only the public TV."