By Steve Almasy
(CNN) -- As dawn broke in Istanbul on Saturday, Turkey's largest city, it was still unclear whether an attempt by the military to wrest control from President Recep Tayyip Erdogan had been successful.
A defiant Erdogan addressed crowds in the city, telling them that the coup had been quashed. "The government is in control," he told supporters.
Overnight, opposition soldiers had attempted to seize control in a number of locations across the country, including the capital Ankara.
Turkish media reported that 42 people -- the majority of whom were police officers -- were killed in Ankara in a gunfire exchange with a helicopter near the parliament complex. The report, from TV station NTV, cited the attorney general's office.
Erdogan, who had traveled overnight from the seaside resort of Marmaris addressed the country Saturday from Istanbul's Ataturk airport, calling the attempt "treason."
While senior government voices were insisting the coup attempt was under control, the situation remains confusing. Reports from witnesses and posted on social media indicate conflict was ongoing.
Witness Katherine Cohen, an American who's staying in an Istanbul hotel, told CNN she heard a loud explosion as the sun rose, and gunfire and jets all through the night. Erdogan addressed Fethullah Gulen, a cleric and former ally who is now who lives in exile in Pennsylvania, who he accused of masterminding the coup.
"Now I'm addressing those in Pennsylvania," he said.
"The betrayal you have shown to this nation and to this community, that's enough. If you have the courage, come back to your country. If you can. You will not have the means to turn this country into a mess from where you are."
The Gulen group denied all involvement.
In Ankara, gunfire was heard overnight throughout the city and jets circled above.
"When I stuck my head out, I could see helicopters shooting," Diego Cupolo, a photojournalist in Ankara told CNN.
He said he could see tracer rounds zip through the air.
Deputy Prime Minister Mehmet Simsek, however, told CNN by phone that the military coup has failed.
"The government is in full control," he said. "Already many of the soldiers involved in Ankara have been arrested."
For much of the night, fighter jets flew low over Istanbul while armored vehicles streamed across a main bridge in the city. Gunshots rang out on that Bosphorus Bridge, sending pro-government protesters down to the ground.
Bombs were thrown at the Parliament building in the capital Ankara. A helicopter the government says was stolen by coup plotters was shot down by an F-16.
And Erdogan was forced to resort to FaceTime on his phone for a TV interview. He urged supporters to go to the streets and stop those who would have him overthrown. They responded by flooding into the squares in Ankara and Istanbul.
Later, Erdogan flew to Istanbul, where he said military factions involved in the coup would be dealt with in the same way the nation treats terrorists.
The United States, United Kingdom and other nations are watching the crisis intently to see what will happen in Turkey -- a member of the NATO Western military alliance, and home to air bases used in the fight against ISIS in Iraq and neighboring Syria.
Chaos in the streets
Tens of thousands of protesters took to the street after Erodgan's call to confront the military was broadcast on television. Many waved Turkish flags and they chanted their support for the President. Some climbed on tanks, some blocked the path of military vehicles with their cars. But some soldiers got hugs from apparent supporters.
The military claimed to have seized power from the government, but the government's National Intelligence Unit said the coup had failed.
Video from the country continues to show confrontations between military forces and street demonstrators. Rinuh Yilmaz, press officer to the National Intelligence Organization, told CNN Turk that "the coup is defeated."
There was no independent confirmation.
But after that claim, soldiers entered the CNN Turk building in the Dogan Media Center in Istanbul, according to the anchor who was on air.
"We don't know how much longer we can continue our broadcast, about five or 10 minutes ago they entered," the CNN Turk anchor said. Minutes later, the camera showed an empty studio. The network resumed broadcasting about 45 minutes later.
A witness in Istanbul told CNN there were several loud explosions about 3:45 a.m., causing buildings to shake. "It sounds like bombings you hear in Syria."
The witness, who was close to Taksim Square and the CNN Turk studios, said the sound of helicopters and jet aircraft flying overhead preceded the explosions.
A fighter jet shot down a helicopter that had been commandeered by "coup plotters," a Turkish presidential source told CNN.
There were reports of gunfire, according to Turkish broadcaster IHA and the U.S. Embassy in Ankara.
The Turkish military claim of a takeover was read by an anchor on state broadcaster TRT. She said the military imposed martial law.
The statement was made on behalf of the "Peace in the Nation" council, the announcer said. "The political administration that has lost all legitimacy has been forced to withdraw," the anchor said. Later, after the military was kicked out, she said she was forced to read the military statement. "We were taken over. I was forced by men with arms and they told us that they would not harm us if we did as told."
When the coup began, soldiers blocked two bridges in Istanbul between the European and Asian sides.
'Go to the streets'
Erdogan said law enforcement was arresting military officers of various ranks amid the ongoing military coup attempt. Speaking from Istanbul Ataturk Airport, Erdogan said the hotel he was visiting in the seaside province of Marmaris was bombed after he left.
He told a nationwide audience the plotters would be dealt with.
"We cannot accept you turning your guns on your parents, brothers and siblings." he said.
Hours earlier, while the coup was just unfolding, a defiant Erdogan showed up on television in a very unusual manner.
"Go to the streets and give them their answer," he told residents during a Facetime interview on CNN Turk.
"I am coming to a square in Ankara. ... This was done from outside the chain of command," Erdogan said of the military. "Those who are responsible, we will give them the necessary punishment," he said. It was not clear from where he was speaking.
He placed blame for the coup on military units he said were influenced by scholar and religious leader Fethullah Gulen, who lives in the United States.
"We categorically deny such claims," said the Alliance for Shared Values, which is connected to the cleric.
In a statement sent to media, the group said: "We condemn any military intervention in domestic politics of Turkey."
Unclear who is in charge
Earlier, Prime Minister Binali Yildirim vowed the coup attempt would not succeed.
He told state news agency Anadolu the coup is "an attempt against democracy and the will of the people. Those who attempted this will pay the heaviest price."
The military has issued statements, which have been published in some Turkish media, and not others, and reported by the Reuters news agency, claiming it has "fully seized control of Turkey" to maintain democratic order, that rule of law must remain a priority and international relations must remain. The statements have not been distributed through regular web channels.
A CNN producer said that as the protests began there were 200 to 300 residents in Taksim Square in Istanbul. Many of them were waving Turkish flags. About 100 police officers were shooting off tear gas, trying to disperse the crowd.
At least one army tank and one other military vehicle were at the square.
Shots have been fired and explosions have been heard in Ankara as the coup continues, according to the U.S. Embassy in Ankara.
The U.S. Embassy said in a statement: "We urge U.S. citizens to contact family and friends to let them know you are safe. We have seen reports that social media is blocked ... We encourage U.S. citizens to shelter in place and do not go the U.S. Embassy or Consulates at this time."
"The United States views with gravest concern the events unfolding in Turkey," a statement by Secretary of State John Kerry said. The statement said the United States is monitoring "a very fluid situation."
Kerry spoke with Turkey's Foreign Minister Mevlut Cavusoglu and "emphasized the United States' absolute support for Turkey's democratically-elected, civilian government and democratic institutions."
NATO Secretary-General Jens Stoltenberg said he had also spoken with the foreign minister.
"I call for calm and restraint, and full respect for Turkey's democratic institutions and its constitution. Turkey is a valued NATO ally," he said.
Erodgan came to power in 2003
Erdogan is the co-founder of Turkey's ruling Justice and Development Party (AKP). He was elected Prime Minister in 2003. Under his rule, Turkey became a powerhouse in the Middle East. His reign came to an end in 2014, and his own party's rules prevented him from seeking a fourth term.
So, he ran for president -- and won. Before this, the president of Turkey was a largely ceremonial role, but Erdogan tried to change that by altering the constitution to give him more power.
The 2015 election resulted in a hung Parliament, leading to sweeping anti-government protests and terror attacks. Turkey held a snap election, and with that, Erdogan's AK Party regained control.
Under Erdogan, who is extremely conservative, religion had started to play a more important role in Turkey, which is a largely secular country. He was active in Islamist circles in the 1970s and 1980s.
Erdogan is open about his dislike of social media.
Sites such as YouTube and Facebook are frequently blacked out in the country.
CNN's Gul Tuysuz, Kevin Bohn, and Amanda Wills contributed to this report.