ANKARA (Reuters) - For two years, Haci Ali Durmaz says he used to cross the Turkish border into Syria, join the ranks of Islamic State for a few months, and then return to Turkey to work in construction.

FILE PHOTO: A pair of shoes, belonging to a street vendor who was selling Turkish traditional bagel or simit, is placed at the October 10 bombing scene during a commemoration for victims, in Ankara, Turkey, October 12, 2015. REUTERS/Umit Bektas/File Photo

Now on trial for involvement in Turkey’s deadliest suicide bombing, an attack last year that killed more than 100 people in Ankara, his testimony has highlighted flaws in border security and intelligence which lawyers say has allowed parts of Turkey to become a rear base for jihadists.

The Turkish government has improved border security since the bombing and a spate of other attacks, but the consequences of such breaches are potentially far-reaching.

President Tayyip Erdogan portrays Turkey as a barrier to Islamic State reaching Europe from Syria and Iraq. Dropping its guard, he says, would enable militants to spread a flood of “fire and blood” through the world.

“First I joined the Nusra Front,” Durmaz said during the first week of the trial in an Ankara court, referring to what was at the time al Qaeda’s affiliate in Syria.

“Then my friends joined Islamic State, and I had sympathy for it, so I joined them,” he said. “I attended military training with them, fought with them for a few months, then came back to Gaziantep (near the border with Syria). This happened, back and forth, three or four times (between 2012 and 2014).”

Durmaz, 19, is one of 14 suspected members of Islamic State who have appeared in court over the attack outside Ankara’s main train station on Oct. 10, 2015, which killed mainly young pro-Kurdish and left-wing activists at a rally.

A further 22 suspects are on trial but some are still at large and some have spoken via videolink. Some face multiple sentences of up to 11,750 years for murder, membership of a terrorist organization and seeking to change the constitutional order. Others face up to 22 years in jail for membership of Islamic State.

Durmaz denies accusations of being in charge of the border for Islamic State and helping plan the suicide bombing, but makes no secret of his trips to Syria.

Asked by the judge whether he had killed anyone there, he said: “We were fighting against the Kurdish militants and (Syrian President) Assad’s regime. It wasn’t an exchange of roses.”

Durmaz’s older brother, Yunus Durmaz, is listed in the indictment as a mastermind of the attack, but blew himself up in May during a police raid on an Islamic State safe house which the younger Durmaz brother survived.

Slideshow ( 2 images )

GARLIC FARM

The defendants have appeared in court behind a line of riot police in body armor and helmets, with the families and lawyers of the victims at times chanting “murderers” and demanding the state also accept responsibility.

Several defendants told the court that for years it had been easy for militants to come and go from Syria, move around enough fertilizer to make bombs and carry out attacks.

One, Yakub Sahin, said he had bought the fertilizer used in the bombing. He said he believed he was buying the ammonium nitrate so that his boss, Halil Ibrahim Durgun, could start a garlic farm. Durgun killed himself in May during the raid on the Islamic State safe house in Gaziantep near the Syrian border.

“The first shop I asked was suspicious, and called the police. The police came to my house and talked to my sister, but they didn’t ask me anything,” Sahin told the court.

He said he was also given the task of escorting the car carrying the bombers. But he said he had believed they were taking a friend who had not done compulsory military service to Ankara and that an escort vehicle was needed to sound the alarm in case there were police checkpoints on the road.

In his testimony to police, seen by Reuters before the trial, Sahin said that, like Durmaz, he was initially recruited to join the Nusra Front in Gaziantep, near the border with Syria. He said he was later introduced to Durgun by a childhood friend and soon realized he was working for Islamic State.

Turkish prosecutors say an Islamic State cell in Gaziantep set up safe houses to accommodate fighters and planned a string of bombings in Turkey.

WORRIED ALLIES

The security of the border between Syria and Turkey, a member of the NATO military alliance and the U.S.-led coalition against Islamic State, has long worried Ankara’s Western allies.

Turkey has been hit by at least half a dozen suicide attacks blamed on the militant group over the past year, including suicide bombings in Istanbul in January and March which killed German and Israeli tourists, and a gun-and-bomb attack at Istanbul airport which killed 45 people in June.

Border security has since been tightened, including by launching a military incursion into Syria to push Islamic State back from the frontier in August. The advance began days after a suicide bomber killed more than 50 people at a wedding in Gaziantep, and weeks after a failed coup in Turkey.

“Turkey is really like a barrier between terror groups and the rest of the world, notably Europe,” Erdogan told a NATO conference in Istanbul on Monday.

“If we are unsuccessful in this fight, that is if this barrier is destroyed, the terrorists will spread fire and blood across the whole world like a flood,” he said.

The security services have made significant inroads against the Islamic State network in Turkey, raiding numerous safehouses in cities around the country, detaining hundreds of suspects and tightening border security.

But its efforts do not stop there. Construction of a concrete wall along the entirety of the about 900 km (560-mile) border with Syria is due to be completed next year at a cost of some 2 billion lira ($600 million).

For the families in the Ankara courthouse, where the next hearing in the trial of the bombing suspects will be next February, such efforts come too late.

“This case is yet another proof that the radical Islamists had a free pass to move around the two sides of the border for years,” said a lawyer for one family whose son, a university student, was killed in the attack.

($1 = 3.3586 liras)