Two British men were arrested as they tried to cross from Turkey to Syria to join the so-called Islamic State, a court has heard.
Hanzalah Patel, 22, of Leicester, and Safwaan Mansur, 22, of Birmingham, deny preparation of terrorist acts.
The pair were held in 2017 after a contact they thought was helping them turned out to be a US government agent, Birmingham Crown Court was told.
They were flown back to Heathrow Airport and arrested by UK police.
Simon Davis, prosecuting, told the jury the men had travelled with the "intention" of crossing into Syria.
"At the time much of that territory was held by so-called Islamic State, a proscribed terrorist organisation," he said.
"In 2017, they were going to join Islamic State and in doing so commit terrorist acts."
Outdoor survival gear
The court heard that in May 2017, Mr Mansur was in contact with a user of the encrypted messaging site Telegram, who was in fact working for the US government.
The jury was told that, when the two men arrived in Istanbul and checked into a hotel, they contacted the man and said another contact had failed to pick them up.
He told them he would send someone to help them, but after they revealed their whereabouts, they were arrested.
A search of their recovered luggage revealed camping equipment and outdoor survival gear, the court heard.
The jury was told the men had been reported as missing by their families.
Police searched their homes and also went to the Darul Uloom Muslim boys' boarding school in Leicester, which both men had attended.
Mr Davis said in 2016 the pair had reached Hatay in Turkey and made an unsuccessful attempt to reach Syria.
In a police interview, Mr Mansur said they had been to Hatay because it was on TripAdvisor and visited by tourists, Mr Davis told the court.
Richard Thomas, representing Mr Patel, but speaking on behalf of both defendants, told the jury that they would be explaining "their hopelessly naive and idiotic plans".
He said they wanted to cross over the border for a short time to see something of what was going on, "securing bragging rights on their return".
Mr Patel, 22, of Frederick Road, Highfields, and Mr Mansur, 22, of Hampton Road, Aston, both deny preparation of terrorist acts between May 31, 2017 and June 24, 2017.
The trial continues.