ANKARA/ISTANBUL - At the height of the attempt to overthrow Turkish President Tayyip Erdogan, the rebel pilots of two F-16 fighter jets had Erdogan's plane in their sights. And yet he was able to fly on.The Turkish leader was returning to Istanbul from a holiday near the coastal resort of Marmaris after a faction in the military launched the coup attempt on Friday night, sealing off a bridge across the Bosphorus, trying to capture Istanbul's main airport and sending tanks to parliament in Ankara."At least two F-16s harassed Erdogan's plane while it was in the air and en route to Istanbul. They locked their radars on his plane and on two other F-16s protecting him," a former military officer with knowledge of the events told Reuters."Why they didn't fire is a mystery," he said.A successful overthrow of Erdogan, who has ruled the country of about 80 million people since 2003, could have sent Turkey spiralling into conflict and marked another seismic shift in the Middle East, five years after the Arab uprisings erupted and plunged its southern neighbour Syria into civil war.A senior Turkish official confirmed to Reuters that Erdogan's business jet had been harassed while flying from the airport that serves Marmaris by two F-16s commandeered by the coup plotters but that he had managed to reach Istanbul safely.A second senior official also said the presidential jet had been "in trouble in the air" but gave no details. Erdogan said as the coup unfolded that the plotters had tried to attack him in the resort town of Marmaris and had bombed places he had been at shortly after he left. He "evaded death by minutes", the second official said.Around 25 soldiers in helicopters descended on a hotel in Marmaris on ropes, shooting, just after Erdogan had left in an apparent attempt to seize him, broadcaster CNN Turk said.Prime Minister Binali Yildirim had also been directly targeted in Istanbul during the coup bid and had narrowly escaped, the official said, without giving details.Flight tracker websites showed a Gulfstream IV aircraft, a type of business jet owned by the Turkish government, take off from Dalaman airport, which is about an hour and a quarter's drive from Marmaris, at about 2240 GMT on Friday.It later circled in what appeared to be a holding pattern just south of Istanbul, around the time when a Reuters witness in the airport was still hearing bursts of gunfire, before finally coming in to land.Gunfire and explosions rocked both Istanbul and Ankara through Friday night, as the armed faction which tried to seize power strafed the headquarters of Turkish intelligence and parliament in the capital. At one point it ordered state television to read out a statement declaring a nationwide curfew.But the attempt crumbled as forces loyal to Erdogan pushed the rebels back and as the Turkish leader, at one point appearing on broadcaster CNN Turk in a video call from a mobile phone, urged people to take to the streets to support him.More than 290 people were killed in the violence, 104 of them coup supporters, the rest largely civilians and police officers. The aerial aspect of the plot appears to have centred on the Akinci air base around 50 km (30 miles) northwest of Ankara, with at least 15 pilots involved under the orders of a rebel commander, according to the former military officer.The head of the armed forces, Hulusi Akar, was held hostage at the base during the coup attempt but was eventually rescued. Jets from Akinci piloted by the rebels roared low over Istanbul and Ankara repeatedly during the chaos of Friday night, shattering windows and terrifying civilians with sonic booms.Fighter jets taking off from another air base at Eskisehir, west of Ankara, were scrambled to bomb Akinci and try to stop the rebels. However, the rogue aircraft were able to keep flying through the night by refuelling mid-air after a tanker plane was commandeered, the first senior official said.The tanker aircraft was taken from the Incirlik air base in southern Turkey, which is used by the U.S.-led coalition to bomb Islamic State in Syria and Iraq. The commander of Incirlik was detained on Sunday for complicity, the official said.MASTERMINDSThree senior officials in Ankara said Akin Ozturk, head of the air force until 2015 and a member of High Military Council (YAS), the top body overseeing the armed forces, was one of the masterminds of the plot. He was among thousands of soldiers detained, pictured on Sunday in handcuffs wearing a striped polo shirt at Ankara police headquarters.Ozturk was due to be retired this August at a meeting of the YAS, which convenes twice a year. According to his biography, still on the military's website, he was born in 1952.The second mastermind was thought to be Muharrem Kose, a former legal adviser to the chief of military staff, the same three Ankara officials said. They described Kose as a follower of Fethullah Gulen, a U.S.-based cleric whose network Erdogan has blamed for carrying out the coup attempt.Kose was removed from his post in March for misconduct but had not been discharged from the armed forces, one of the officials said. His whereabouts are currently unknown."There were serious preparations ongoing for a very long time. The two people in question seem to have been the brains behind the coup attempt," the official said, declining to be identified because the investigation is still continuing.Erdogan and the government have long accused Gulen's followers of trying to create a "parallel structure" within the courts, police, armed forces and media with the aim of seizing power, a charge the cleric has repeatedly denied."NOT FULLY PREPARED"Erdogan, his roots in Islamist politics, has always had a difficult relationship with the military, which long saw itself as the guardian of secularism in Turkey, carrying out three coups and forcing a fourth, Islamist-led government from power in the second half of the 20th century.Coup plot trials saw hundreds of officers jailed while Erdogan was prime minister, as the government used the courts to clip the wings of the armed forces. The allegations were later discredited and convictions overturned, but the actions damaged morale and fuelled resentment.Yet the coup plotters appear to have overestimated the support they would find within the military ranks."It was outside the chain of command which was the biggest handicap for the coup plotters," said Sinan Ulgen, a visiting scholar at Carnegie Europe and a former Turkish diplomat."They had an insufficient portfolio of resources. They were grossly under-equipped to achieve their strategic objectives ... There was definitely quite a degree of incompetence compared to how coups were done here in the past."At one point they tried to silence CNN Turk, forcing the evacuation of the studio. When it came back on air, anchorwoman Nevsin Mengu described the soldiers as young and with "only fear in their eyes and no sign of devotion or determination".The former military officer said the coup plotters appeared to have launched their attempt prematurely because they realized they were under surveillance, something corroborated by other officials in Ankara."They weren't fully prepared. The plans were leaked, they found out they were being monitored and it all apparently forced them to move faster than planned," the ex-officer said.They also underestimated Erdogan's ability to rally the crowds, his appeal for supporters to take to the streets bringing people out in Istanbul, Ankara and elsewhere even as tanks took to the streets and jets screamed overhead.Sertac Koc, press adviser to the mayor of Kazan district where the Akinci base is located, said local residents started noticing the high number of jets taking off as events unfolded."When they saw jets hitting parliament in Ankara and people in Istanbul, they got organized among themselves and marched to the base to try and stop them," he told Reuters by phone."They tried to block traffic to the base by parking their vehicles, burning hay to block the jets' vision, and in the end they attempted to cut the power to the base," he said.Seven people were killed when the rebel soldiers opened fire, Koc said, among the dozens of civilians killed across the country in one of Turkey's worst nights of bloodshed.