Five migrants were reportedly injured when they climbed to the top of a border fence in northern Africa and became stuck there for several hours.

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.

ACNUR observa de cerca y con preocupación la situación de unas 50 personas encaramadas en la valla de #Ceuta (1/3) — ACNUR España (@ACNURspain) September 10, 2016

ACNUR reitera la obligación de las autoridades de dar acceso al territorio y al asilo a quienes necesitan protección internacional (2/3) — ACNUR España (@ACNURspain) September 10, 2016

La posición de ACNUR sobre devoluciones automáticas, que se constata como 1 práctica creciente, se refleja en https://t.co/Nu1V1YbFlh (3/3) — ACNUR España (@ACNURspain) September 10, 2016

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.

Salto a la valla en estos momentos por la zona del #Tarajal#Ceutapic.twitter.com/b0cC6OHQKW — MOHAMED ALI (@M_ALI_LEMAGUE) September 10, 2016

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.

READ MORE: Blade runners: 5-meter razor-wired wall planned to keep Moroccan migrants out of Spain