Carrying only a change of clothes, a flashlight and a screwdriver, the 25-year-old cycled thousands of kilometers across the continent, passing through jungles, deserts and conflict zones in the hope of landing a place and finding a way to fund it.
Four months and seven countries later, he is in Cairo with a full scholarship to Al-Azhar University, one of the world's oldest and most renowned Sunni Muslim learning institutions.
"If you have a dream, stay with it and be strong," Barry said, adding, "God will help you."
Thousands of West Africans like Barry undertake risky journeys across the Sahara desert each year, searching for a better life. Many never make it.
Nearly 500 people died or disappeared on West African migration routes last year, data from the International Organization for Migration shows.
Barry decided the risk was worth the reward.
"I had to fight," Barry said last month in Chad.
Covering approximately 100 km each day, Barry pedaled through Mali, Burkina Faso, Togo, Benin, and Niger before stalling in N'Djamena, the Chadian capital, shaken from his planned route by an ongoing conflict in Sudan.
He said he had already been detained three times - twice in insurgency-plagued Burkina Faso and once in Togo, where security forces held him for nine days without charge before releasing him in exchange for 35,000 CFA francs ($56).
This was the entirety of his savings for the remainder of the journey, he said.
Mamadou Safaiou Barry walks on his way to the center where he studies Islam and the Koran, in El Marg district in the east of Cairo, Egypt, September 23, 2023.
"I often slept in the bush because I was afraid of people in the cities," Barry said.
"I thought they would take my bike and hurt me," he added.
Barry's luck changed again in Chad after a local philanthropist, who had read online about his journey, offered to fly him directly to Egypt and bypass the fighting in Sudan.
Barry arrived in Cairo on Sept. 5 and days later secured a full scholarship to Al-Azhar.
A photo shared widely on social media shows him meeting a beaming university representative.
He intends to return to Guinea when his studies are complete, to spread the faith that has taken him so far. "When I return to my country, I would like to be someone who teaches Islam and tells people how to do good things," he said.