Two men who travelled to Syria to join rebel fighters have admitted preparing to carry out terrorist acts.

Childhood friends Mohammed Nahin Ahmed and Yusuf Zubair Sarwar, both 22, spent eight months in the wartorn country last year after contacting Islamic extremists from the UK.

The men, from Handsworth, Birmingham, were arrested at Heathrow by West Midlands police's counter-terrorism unit on their return in January after their families had put pressure on them to return to Britain.

Sarwar's family had reported him missing in May last year after they found a handwritten letter saying he had left to join a terrorist group called Kataib al-Muhajireen (KaM) to take part in jihad. Days earlier he had told his family he was travelling to Turkey for a two-week trip organised by Birmingham City University, where he was a part-time computer science student.

Police searched the men's homes, revealing an online conversation between Ahmed and a Swedish national fighting with the KaM, during which Ahmed said he wanted to join the group. He wrote on Skype: "I come to join KaM," to which the Swede replied: "Inshallah (God willing)".

Ahmed later asked a Danish extremist: "Would the brothers in Yemen accept me?" Online conversations between Sarwar and Ahmed also revealed Ahmed's plan to travel abroad to join the jihad. He told Sarwar: "I cannot tell anyone I'm going to jihad. Lol. I'll get arrested."

Police said the men showed the mindset to join the jihad, before carrying out research, buying equipment and travelling via Turkey to Syria. After their arrest the pair told officers their trip had been for humanitarian reasons. But police found thousands of images of them with guns on a digital camera.

Specialists said the pictures showed they had been in and around Aleppo, the scene of ongoing fighting between Syrian government troops and rebels. Traces of military-grade explosives, including TNT and nitroglycerine, were also found on their clothes and trainers.

Images of Islamic propaganda were found on both men's computers, including pictures of the Islamic State flags, martyr literature and several texts linked to the jihadi mindset.

Ahmed and Sarwar each admitted one count of engaging in conduct in preparation of terrorism acts at Woolwich crown court in London on Tuesday.

Judge Topolski QC said he would not pass sentence until a court of appeal decision about a similar case had been heard later this summer. He described the case as "grave", and told the court that together Ahmed and Sarwar had "carefully planned a journey from the UK to Turkey and on to Syria to join Islamist rebels fighting the regime of Bashar al-Assad".