Turkish Prime Minister Binali Yildirim says 2,839 members of military have been detained in connection with an attempted coup. (Reuters)

The arrests of thousands of military officers, soldiers and other suspects linked to a failed coup in Turkey have opened a punishing campaign by the authorities against alleged plotters amid signs of chaos in the armed forces.

Turkey’s justice minister confirmed that as many as 6,000 people — including generals and a commander of an air base used by U.S. warplanes to target Islamic State militants — had been detained by early Sunday.

That so many have been arrested suggests a crackdown on President Recep Tayyip Erdogan’s opponents in a move to further consolidate his power. But the sweeping action has raised concerns of more instability for a pivotal U.S. partner in the turbulent Middle East.

“What we saw appears to show serious fracturing in Turkey’s military,” said Soner Cagaptay, director of Turkish research at the Washington Institute for Near East Policy. The country’s armed forces have long been respected as a guardian of stability by many inside and outside this regional powerhouse of 75 million people.

“This is the second-largest military of NATO, an ally of the U.S. that borders Iran, Iraq, Syria, Russia and the Islamic State,” Cagaptay said. “And the last thing Washington wants is to see such an influential NATO member’s military fracture.”

Among those arrested was the commander at Incirlik Air Base, which is used by U.S. forces to launch raids against Islamic State militants in Iraq and Syria, a senior Turkish official said, speaking on the condition of anonymity.

Gen. Bekir Ercan Van was detained along with 10 other service members Sunday. The base is a major NATO installation hosting U.S. forces that control a stockpile of nuclear weapons.

The U.S. Consulate in the southern Turkish city of Adana said Saturday that authorities had cut power to Incirlik and blocked movement to and from the base. Turkey also closed its airspace to military aircraft. But the Pentagon said Sunday that the country’s airspace had opened again and that all anti-
Islamic State operations had resumed.

“U.S. facilities at Incirlik are still operating on internal power sources, but we hope to restore commercial power soon. Base operations have not been affected,” the Pentagon’s press secretary, Peter Cook, said in a statement.

As many as 3,000 Turkish service members have been detained by authorities in response to the coup attempt, during which at least 265 people were killed.

Rogue officers of Turkey’s military declared martial law and attempted to overthrow the government of President Recep Tayyip Erdogan overnight, but Erdogan a few hours later said his government is in control. (Jason Aldag/The Washington Post)

The arrest of so many, in multiple branches of the armed forces in locations across the country, indicates that a significant minority of the military either participated in or indirectly supported the coup attempt, said Aaron Stein, an expert in Turkish politics and a resident senior fellow at the Atlantic Council’s Rafik Hariri Center.

Among those arrested was Gen. Akin Ozturk, a former commander of the Turkish air force and military attache to Israel who is a member of the Supreme Military Council.

Another is Gen. Adem Huduti, commander of the Second Army, which protects Turkey’s borders with Syria, Iraq and Iran. And Rear Adm. Hakan Ustem, commander of the coast guard, was removed from his post, said a senior Turkish official, speaking on the condition of anonymity because he was not authorized to discuss the subject. It was unclear whether Ustem had been arrested.

“What’s important is how widespread it was,” Stein said. “It’s a minority, but a relatively large minority, and they were able to inflict quite a lot of damage.”

Turkey has a history of military coups, with generals ousting civilian governments in 1960, 1971 and 1980. But such incidents have usually involved overwhelming support from within and across the various branches of the armed forces — unlike Friday’s thwarted putsch, Cagaptay said.

“The latest coup attempt is different, because it actually highlighted how the chain of command has broken down,” he said.

Arrest warrants have also been issued for at least 2,745 judges and prosecutors across the country, according to Turkish media reports.

Erdogan seems to have been emboldened after overcoming the biggest challenge to his 13-year rule, with thousands of supporters taking to the streets in Istanbul and other areas of the country in defiance of the military personnel who hatched an elaborate plot to overthrow the government.

The Turkish leader has alarmed many here with his attempts to consolidate power over the years. Some Turks have expressed concern that Erdogan will use Friday’s incident to further marginalize all forms of challenge to his growing powers, whether peaceful or not, even as the country struggles with myriad crises. Those include deep divisions over the role of Islam in Turkish politics, worsening unrest from within the large minority of Kurdish citizens and spillover from the civil war in neighboring Syria.

Nearly 3 million war-weary Syrians have taken refuge in Turkey.

A series of recent attacks linked to the Islamic State and Kurdish separatists have killed hundreds of people and badly damaged the Turkish economy.

In Ankara, the capital, signs lingered of particularly violent clashes that started Friday night.

Rogue officers used aircraft and tanks to target government buildings, including parliament. Trees on a nearby street were uprooted, and a lamppost was downed.

Mehmet Koskal, 28, who works in a shop selling cigarettes and snacks, took to the streets, heeding Erdogan’s call to defy the coup plotters with popular rallies. Koskal said police and civilians had stormed a military building next to parliament that coup plotters had seized.

He said that gunshots could be heard from inside and that a helicopter then began firing on civilians in the square.

“It was just flying over us and shooting,” said Koskal, who recalled seeing people in the streets who represented most of Turkey’s diverse, and at times divided, political spectrum.

A total of 261 casualties were brought to Ankara’s Numune Hospital, according to staff members. They would not release official figures on how many died, but orderlies said that at least 50 to 60 had either been brought in dead or died later from wounds.

Erdogan on Sunday attended a mass funeral in Istanbul for five people killed in the unrest.

During the services, held at Istanbul’s Fatih Mosque, he again blamed the coup on Fetullah Gulen, a Turkish cleric who lives in exile in the United States. An estranged friend of the Turkish leader, Gulen has denied repeated accusations that he orchestrated the incident. Analysts say Gulen has many supporters who are thought to have deeply penetrated Turkey’s police and judiciary, although they say he holds minimal support in the military.

The throngs of people in attendance had angrier words than Erdogan’s about Gulen, with some even calling for his death.

“We want execution!” someone in the crowd yelled.

Erdogan, however, urged restraint.

“If they have guns and tanks, we have faith,” he told the mourners. “So let us think before taking each step. We will act with reason.”

Loveday Morris in Ankara and Zeynep Karatas in Istanbul contributed to this report.