Let me give you guys some more inside details:
From the start it was clear that something was weird: they weren't enough soldiers to make a real coup, only a few hundred soldiers a few helicopters, tanks, etc... And it seems that they knew it and did it despite that. By the way they even bombed the house where the President was supposed to be...
The coup attempt was made by members of a religious group named "Nurcu" leaded by Fetullah Güllen, who is in exile in the U.S.A. ...
It was known that members of this group had infiltrated every possible area of the government (possible, legal branch, army,etc...)
Yes this group was the biggest ally of Erdogan during more than 10 years and it is mainly because of Erdogan that these people infiltrated so well every aspect of the government. They together imprisoned falsely reporters, policemen and soldiers claiming they were attempting to make a coup. They even imprisoned the former Chief of Staff. And those idiots in the AKP government and people who supported Erdogan were cheering them because they were getting rid of "secular" forces in the army. Now irony is these same people are doing exactly what they were supposedly trying to prevent: Make a Coup.
The Turkish army was always saying that the biggest danger for the country was religious backwardness(irtica) and unfortunately it has proven right again.
Although they were shots fired to civilians and to cops, the civilian crowds didn't hurt the few soldiers on the streets they grab them and handed them to the police. The situation is getting better, the Chief of Staff was saved (he was hostage by these people) the commanding officers are calling these soldiers back to their base to be arrested. Most of them are coming back. They even shot a helicopter("rebel") with an F-16.
I think the situation will settle in maximum 24H.
Unfortunately I think this will give Erdogan more power and leverage on the long run and drive the country deeper in insanity. Turkey is on its way to become the "Pakistan" to Syria/Irak, the Afghanistan of the middle-east.
For the better or the worse the only thing keeping Turkey from being another middle-eastern country was(unfortunately) the army.