The migrants were attempting to enter the Spanish enclave of Ceuta on the north coast of Africa from neighboring Morocco when they became trapped on top of the six-meter-high wire fence.

Around 150 migrants were attempting to illegally enter Spain by climbing over the fences surrounding the Ceuta border crossing when some 85 people climbed on top to avoid being caught by the authorities, officials said in a statement.

Video of the incident shows dozens of people sitting on top of the fences, which are covered with barbed wire.

The UNHCR said they were monitoring the situation with concern and reminded Spain of their obligation to provide asylum to those in need of protection.

Authorities eventually removed the people from their position atop the fence using a crane. Five were taken to hospital to be treated for minor injuries, while the remaining migrants were reportedly returned to Morocco.

One of the migrants involved, who had traveled from Cameroon to attempt the crossing, described those on top of the fence as singing songs despite their ripped clothes and injuries, according to El Faro de Ceuta.

The European Union and Africa share only two land borders, Ceuta and Melilla, both of which are crucial crossing points for illegal African migrants entering Europe. Fifteen people died in February while trying to reach Ceuta from a Moroccan beach.