A coup attempt by an army faction in Turkey has been put down, Turkish Prime Minister Binali Yildirim said, after thousands of people heeded a call from President Recep Tayyip Erdogan and took to the streets.

Yildirim told broadcaster NTV that a no-fly zone had been declared over the capital, Ankara, blaming followers of US-based preacher Fethullah Gulen.

"The coup attempt is foiled," Turkey's national intelligence agency had earlier said in a statement.

Sections of the Turkish army had earlier officially declared a coup and martial law, saying that they had "taken control of the country" as Istanbul's main airport was closed and fighter jets were seen in the skies.

Erdogan in a phone call to broadcaster CNN Turk on Friday said he remained the president of the country and the head of the army and called for people to take to the streets against the coup.

"We will overcome this," Erdogan said, speaking on a video call to a mobile phone held up to the camera by a presenter. He called on his followers to take to the streets to defend his government and said the coup plotters would pay a heavy price.

An official said Erdogan was speaking from Marmaris on the Turkish coast where he was on holiday. Erdogan said he would swiftly return to Ankara.

WATCH: Our rolling coverage of the attempted coup in Turkey

In the capital Ankara, gunshots and loud explosions were heard, as military jets and helicopters were seen flying overhead, a Reuters news agency witness said. The state-run Anadolu Agency reported that a military helicopter had attacked the Ankara police headquarters and Reuters said the parliament was surrounded with tanks.

Another Reuters witness reported hearing gunfire at Istanbul airport.

"We know they have been acting outside the chain of command," Cemalettin Hasimi, a government spokesman told Al Jazeera, referring to the sections of the army behind the coup attempt.

"But forces of democracy have managed to take the situation back under control. The parliament will get together in half an hour."



An Al Jazeera correspondent in the coastal city of Izmir reported an unusually heavy military build-up in the city earlier in the day.

LIVE BLOG: Minute-by-minute updates on developments across Turkey

In Gaziantep, a city in the south, Al Jazeera's Zeina Khodr reported that supporters of Erdogan had taken to the streets. Cars could be seen streaming towards the airport, honking their horns.

The Dogan news agency quoted the military members on Friday as saying that they wanted "to reinstall the constitutional order, democracy, human rights and freedoms, to ensure that the rule of law once again reigns in the country, for the law and order to be reinstated".

The statement went on to say that "all international agreements and commitments will remain. We pledge that good relations with all world countries will continue".

Earlier, speaking on television, Turkish Prime Minister Binali Yildirim said that a number of generals were involved in what he called an attempted coup.

'Dissent in the military'

He vowed that the "perpetrators" would be contained, adding that the government would "never give up democracy".

Al Jazeera has learned that Istanbul's Ataturk international airport has been shut down and all flights have been cancelled.

An Al Jazeera reporter in Istanbul reported seeing military officers arriving at the central Taksim Square, and ordering everyone to leave.

"They were evacuating the entire square," our reporter said. "People are going home now."

Separately, a TRT World reporter told Al Jazeera that soldiers had entered the government-funded television network's building, ordered the channel off the air and taken the phones of staff members.

Istanbul's Bosphorus Bridge and Fatih Sultan Mehmet Bridge were shut down by the army, local television channels reported. The two major bridges connect the Asian side of Istanbul to the European side.

Dogan news agency footage showed cars and buses being diverted, according to Reuters.

TIMELINE: A history of Turkish coups

Reuters witnesses in Istanbul, Turkey's largest city, also spotted helicopters overhead.

"It seems there is dissent in the military ranks," Al Jazeera's Zeina Khodr, reporting from Gaziantep, said.

Turkey has had a history of coup attempts, the last in 1997, which forced the resignation of then-prime minister Nemettin Erbakan.