TURKISH security forces captured the suspected gunman who killed 39 people at the Reina nightclub attack in Istanbul on New Year's Eve.

Abdulkadir Masharipov, described by officials as a well-educated terrorist who speaks four languages, was detained by cops in the city's Esenyurt district, just 25 miles from where the deadly assault was carried out.

22 A bloodied Abdulkadir Masharipov pictured following his arrest in Istanbul

22 Masharipov was detained just 25 miles from the scene of the New Year's Eve shooting at the Reina nightclub

22 The suspect was filmed being marched out of a house surrounded by police and reporters

22 Local media reported that the terror suspect resisted arrest

22 The gunman opened fire in a packed nightclub on New Year's Eve in Istanbul, killing 39 people Credit: Enterprise News and Pictures

The Uzbek national, who was operating under the alias Ebu Muhammed Horasani, was caught after over two weeks on the run.

The huge manhunt involved around 1,000 cops, detectives and other officers scouring through 7,200 hours of CCTV footage and over 2,000 public tip-offs.

A special operations task force swooped on a council-owned house reportedly rented by Masharipov's friend on Monday night.

He reportedly resisted arrest and was detained in front of his four-year-old son.

The alleged fanatic, said to be 34-years-old, underwent medical checks before being taken to a police headquarters for questioning.

related stories 'I'M INNOCENT' SECOND man wrongly accused of Istanbul terror attack speaks out after 'his passport is leaked by cops 'I DIDN'T KNOW HE WAS ISIS FANATIC' Istanbul gunman's wife tells cops she only knew of atrocity when she saw it on TV ‘MY HEART GOES OUT TO HER FAMILY' CBB star Shilpa Shetty pays tribute to fashion designer pal killed in Istanbul attack NEW YEAR TERROR What happened in the Istanbul attack and who carried out the New Year's Eve nightclub shooting? INCHES FROM DEATH Istanbul attack victim cheats death when Santa killer's bullet bounces off his MOBILE PHONE HUNT FOR isis SANTA KILLER ISIS claims responsibility for Istanbul attack that left 39 dead in New Year's Eve nightclub Video SANTA CLAUS KILLER Moment terrorist dressed as Santa guns down 39 in Istanbul nightclub in New Year's Eve massacre

Officials said he confessed to carrying out the massacre shortly after interrogation began.

Prime Minister Binali Yildirim told reporters: "The vile terrorist who attacked the place of entertainment on New Year's eve and led to the loss of so many lives has been captured".

He added: "What is important is for the suspect to be captured and for the forces behind it to be revealed."

Istanbul governor Vasip Sahin said that the captured nightclub attack suspect is an Uzbekistan national who trained in Afghanistan.

He is believed to have entered Turkey illegally in January 2016, and arrived in the city on 15 December.

22 The living room of a hideout where the alleged attacker of Reina nightclub was caught by Turkish police on Monday night Credit: Reuters

22 Filthy flat in Esenyurt is where police swooped on terror suspect and three alleged accomplices Credit: Reuters

22 A copy of the Koran sits in the flat where Abdulgadir Masharipov was found Credit: Reuters

22 Bags of cash from several countries was found in one of the bedrooms Credit: Reuters

22 A note which says the author will 'be in the other place' was among documents uncovered at the flat Credit: AP:Associated Press

22 Reporters stand near the door to the flat which was blasted open by police on Monday night Credit: Reuters

22 A man walks through the kitchen where four people were arrested Credit: Getty Images

Dogan news agency published what it said was the first image of the alleged attacker.

It showed a bruised, black-haired man in a grey, bloodied shirt being held by his neck.

The alleged gunman's friend, reportedly from Iraq, and three women from Somalia, Senegal and Egypt were also were detained.

His son was taken into protective custody following the police raid.

Earlier, his wife and one-year old daughter were caught in a police operation on January 12.

Police established his whereabouts four or five days ago, but delayed the raid so they could monitor his movements and contacts, NTV reported.

The television channel also broadcast footage showing plain-clothed police taking away a man in a white top and sweat pants, forcing his head down.

The station said the images showed the gunman's Iraqi friend being taken to a police vehicle.

22 Police released this still of the alleged killer from his 'selfie video'

22 Shooter was filmed on CCTV blasting party-goers as he stormed nightclub Credit: Twitter

Police were carrying out raids on other suspected ISIS group cells at the same time.

Turkish Foreign Minister Mevlut Cavusoglu posted a Twitter message thanking the interior minister, Suleyman Soylu, police and intelligence organisations "who caught the Reina attacker in the name of the people."

Depraved terror group ISIS claimed the attack was in reprisal for Turkish military operations in northern Syria

The brutal assault took place just 75 minutes into 2017 and also left a reported 69 people in hospital.

At least 600 revellers were celebrating at the popular nightspot in the early hours of New Year’s Day when the attack took place.

The gunman arrived by taxi and produced a weapon, reportedly a Kalashnikov, from the boot before shooting dead a policeman and civilian at the entrance.

22 Another man believed to be an Iraqi was detained in the police raid Credit: Rex Features

22 Police also arrested three women from Egypt, Somalia and Senegal Credit: Haberler

22 Two of the three women arrested along with Abdulkadir Masharipov Credit: Haberler

Masharipov, an Uzbek national, is said to have arrived in the Turkish city from the centre of the country on December 15.

Hurriyet reports that an ISIS cell operating in the central region of Konya consists of Uzbeks who provided Masharipov with support.

Uzbek fighters have become deeply embedded in ISIS and have fought alongside the Taliban in Afghanistan.

They are also said to have secret outposts in some major Russian cities as well as having ties to Muslim extremists in China.

22 Harrowing pictures show the carnage left inside the Istanbul club after the shooting

22 The gunman fired an estimated 120 bullets at clubbers

Turkish Deputy Prime Minister Numan Kurtulmus has said the nightclub attack had been carried out professionally with the help of an intelligence organisation.

He did not name the organisation suspected of being involved.

Hundreds of people were gathered at the swanky Reina nightclub to celebrate the end of a tumultuous 2016 only to become the first victims of 2017.

Most of the dead in the attack on the upscale club were foreign nationals, from the Middle East.

The gunman reportedly left Reina in a taxi.

22 CCTV footage shows the man believed to have carried out the massacre in Istanbul

22 Paramedics rushed the scores of wounded people to ambulances after the Istanbul nightclub attack Credit: Reuters

22 Relatives mourn Fatih Cakmak, 35, a security guard who died in the Reina nightclub attack Credit: Getty Images

Following the massacre distressing images later showed the aftermath of the massacre, with the bloodied bodies of the victims piled on top of each other.

According to reports, terrified partygoers lept into the freezing waters of the Bosphorous river to escape the horrific scenes.

It was initially reported that the killer entered the nightclub wearing a Santa hat, based on early CCTV footage of the attack.

But the Turkish Prime Minister Binali Yildrim has said there was no truth to the reports.

We pay for your stories! Do you have a story for The Sun Online news team? Email us at tips@the-sun.co.uk or call 0207 782 4368