June 2013 may go down as the month when Turkey’s prime minister Recep Tayyip Erdogan lost the image of political invincibility that helped him to win three landslide elections and mould the country in his image.

If so, he may well blame social media, which has carried forward a tsunami of popular anger at his style and some of his policies. They have broken his aura.

The army of Twitter, Facebook and YouTube users, using today’s do-it-yourself media to get around a blanket of state censorship, have emerged as a coherent, if diverse, opposition to Mr Erdogan’s increasingly intolerant rule.

Their main weapons, during their initial ‘18-day protest’ of Gezi Park in Istanbul, have been online videos of police attacks that have left at least four dead and hundreds injured; photos on Flickr and Tumblr; tweets and retweets; and an array of smartphone apps to get around government efforts to impose a selective news blackout.

The prime minister’s condemnation of social media as “a scourge” was the final proof of how effective the protestors have been in getting their message out and generating more resistance.

That became clear in an unexpected and noisy way when thousands of people, including housewives, showed their support by banging kitchen implements at the windows of their flats.

But Turkey’s mainstream media have been catastrophic losers in the battle of June 2013 – their reputations largely trashed for bowing to government pressure.

Major newspapers and TV stations ignored or played down the scale of the protests but carried prominent stories when Mr Erdogan condemned the protestors as “riffraff” and “terrorists”.

In graffiti, the protestors denounced the media as “cowards”. On Twitter, “#rotten media” went viral. Some TV stations were besieged by demonstrators demanding an end to censorship. Posters portrayed Turkey’s big media as the three monkeys (right) of Chinese legend – who ‘see no evil, hear no evil and speak no evil’.

Many Turks have turned to foreign media for uncensored coverage. But when the BBC’s Turkish partner organisation NTV failed to transmit one of the scheduled programmes – about popular anger at the Turkish media’s failure to report the protests – the BBC called the interference “totally unacceptable” and suspended the partnership arrangement.

The BBC’s Turkish language output will continue on all available platforms.

Government pressure on the country’s media is well documented and has been growing tighter. Early on in the protests Turkey’s state media regulator fined four TV stations for showing live footage of battles between protestors and police, alleging that the broadcasts violated rules protecting the “mental development” of young people.

Such pressure is effective because Turkey’s major newspapers and private TV stations are owned by business conglomerates that depend heavily on government contracts. Privately, some have conceded that they dare not make enemies of the Erdogan government, which is quick to wreak revenge on those it sees as its opponents.

Turkey’s largest commercial media business, Dogan Group, was chastened in 2009 when it was ordered to pay fines of billions of dollars in unpaid taxes and fines. The company protested it was being penalised for critical coverage of the government, including allegations of corruption.

Turkey has also attracted international criticism for holding more than 60 journalists in jail, either in pre-trial detention or after being convicted of criminal offences. That now makes Turkey the country with the largest number of imprisoned journalists in the world.

Most of the journalists languishing in Turkish jails are accused under anti-terrorism, state security and insult laws – which have been criticised as contrary to Turkey’s international commitments by, among others, the United Nations Human Rights Committee, the Council of Europe and the European Union.

Several thousand journalists have faced criminal investigations on various counts since Mr Erdogan came to office in 2002, often preventing them from working for long periods. Turkish journalists’ groups say the threat of criminal prosecution or jail has led to widespread self-censorship in all sectors of the news media.

The prime minister has personally attempted to sue dozens of media or journalists for defaming him, winning some cases and losing or dropping others. Among his complaints were cartoons depicting him as a dog, a cat and a horse.

In recent months reports say some of Turkey’s most respected journalists and columnists have been sacked from their posts for no good reason after officials leaned on their employers.

Amnesty International exposed this phenomenon in a recent report that highlighted the case of Amberin Zaman, a celebrated journalist for the Haberturk newspaper as well as the Economist magazine whose Turkish employer dismissed her in April. She wrote that the removal of critical voices like hers was usually prompted by a simple phone call to the editor by someone in the prime minister’s office.

Turkey’s G9 platform, a coalition of journalists’ groups, maintains that most journalists are part of the struggle for freedom of expression but are repressed by media owners who want to be close to the government.

Turkish journalists have fought a long and losing battle for the right to form independent unions. And the G9 platform reports that in recent weeks journalists have been arrested, beaten and injured in targeted violence by police.

The new media landscape has opened up an unpredictable new front in Turkey’s society-wide conflict between free speech and liberal values and Mr Erdogan’s version of guided democracy backed by media controls.