Image copyright Associated Press

Twenty people died and more than 120 were injured in the horrific bombing on 17 August in central Bangkok at the Erawan shrine. But the investigation into who perpetrated the attack has seen conflicting statements and perplexing developments. Here are the twist and turns that took police from knowing very little after the deadly blast, to claiming to have identified their main suspect six weeks later.

The immediate aftermath: conflicting statements

On 18 August, a day after the bomb, another explosion in a canal sent a huge column of water over passers-by, but caused no injuries. Later police identified it as caused by a bomb similar to the one at the shrine.

On 19 August police showed CCTV video, taken from the shrine and surrounding area. In it a man in a yellow shirt, with long hair and thick-framed spectacles, leaves a black backpack beside a bench at the shrine, and walks out just before the bomb explodes.

Image copyright Thai Police HO via AP

The police can ascertain nothing about his identity from the grainy images, and have no information after he was dropped off by a motorbike taxi about a kilometre from the shrine.

On 22 August new CCTV video shows another man kicking a bag into the canal where the 18 August explosion occurred. This took place just 30 minutes after the first bomb.

The police now know they are dealing with a network. But their often conflicting statements undermine public confidence in their competence.

On 24 August the investigation stalls. Police complain that inconsistent witness testimony and broken CCTV cameras are hampering their work.

Image copyright AFP Image caption Soon after this image from CCTV, police lose track of the suspect's location

"We have to use our imagination," admits police chief Somyot Poompunmuang. He says they do not know whether the perpetrators are still in Thailand or not.

Arrests are made: 'But main suspect not caught'

On 29 August there is a breakthrough - police and military officers detain their first suspect, a foreign man carrying a fake Turkish passport, found surrounded by potential bomb-making materials in an apartment north of Bangkok.

The following day they find more materials in another apartment. A Thai Muslim woman and her Turkish husband are also named as suspects. Both are believed to be in Turkey.

On 31 August Chief Somyot brings out a stack of cash - 3m Thai baht ($82,000; £54,000) offered as a reward for information leading to arrests - and gives it to his own officers.

On 1 September the second suspect is detained, after being handed back across the border by the Cambodian authorities.

Image copyright Associated Press Image caption Yusufu Mierali - a muslim from Xinjiang -is identified as a key suspect

He is carrying a Chinese passport that identifies him as Yusufu Mierali, a Muslim from Xinjiang where the Uighur minority lives. Police believe he may have assembled the bomb. They think the yellow-shirt bomber is still at large.

By 5 September a total of 10 arrest warrants have been issued.

Perpetrators are foreign: 'People smugglers are to blame'

On 9 September police identify a man named "Izan" they believe organised the bombing, who left Thailand for Bangladesh the night before the attack. With the help of Bangladesh they trace his movements via Delhi and Abu Dhabi to Istanbul.

Image copyright European Photopress Agency

His passport shows his real name as Abudusataer Abudureheman, a Muslim Chinese citizen from Xinjiang. There is still confusion over whether Thailand has requested any help from Turkey. The Thai police have insisted all along that foreign assistance is not needed.

By now it is clear most of the plotters are foreigners. Both suspects in Thai custody are Muslim Uighurs from China's Xinjiang province, as is "Izan", the man the Thais believe was the ringleader.

Sources who have met the suspects say they speak of repression in Xinjiang and appear to have been radicalised. But the police continue to maintain the bombing was not an act of politically-motivated terrorism, but the work of people smugglers annoyed by Thai anti-trafficking operations.

This despite the growing conviction among terrorism experts that it was most likely retribution for the Thai decision to forcibly repatriate 109 Uighur asylum-seekers to China in July.

Yellow-shirt bomber: 'We had him all along'

Police on 25 September say they now believe that the first suspect they detained, Bilal Mohammed, is the yellow-shirt bomber. They say he confessed to being the bomber on 23 September and that this is supported by new CCTV video and photographs from Yusufu Mierali's camera.

Bilal had until then insisted he was just being smuggled to Malaysia using a false Turkish passport. His unexpected confession was made in military custody, without his lawyer. A source who has seen him tells the BBC he believes Bilal was coerced into confessing.

Image copyright AFP Image caption Police announce the case is solved

A total of 17 arrest warrants have been issued for suspects carrying Chinese, Turkish, Thai and Pakistani passports. Fifteen are still at large, probably outside Thailand. It is not clear what the Thai authorities are doing to track these suspects down.

Outgoing police chief Somyot announces on 28 September that the case is solved, they have the main perpetrators in custody. He displays the 3m baht reward again.

Image copyright Reuters

He also suggests for the first time that there are links with a "political group", and names a man loosely affiliated with the red-shirt movement loyal to ousted Prime Ministers Yingluck and Thaksin Shinawatra, who is wanted in connection with two smaller explosions in 2010 and 2014.

It turns out this man has been living outside Thailand for more than a year, and Gen Somyot backtracks. But other senior officials say they are still looking for him.

On 30 September chief Somyot retires after a year in the job. He still insists the motive for the Bangkok bombing is anger among people-smugglers, not retaliation by militants for deporting Uighurs.

Outside the police very few people are persuaded by Gen Somyot's theory. The two suspects in custody have yet to be charged. When they are, they face trial in a military court, which human rights groups have warned would not be equipped to judge a complex case like this.