The lifting of border controls between Spain and Gibraltar has closed "an open wound," Spanish Prime Minister Pedro Sánchez said on Wednesday as an agreement allowing free movement across the frontier came into force.

Speaking at a ceremony marking the removal of the metal gates separating the Spanish town of La Línea de la Concepción from the tiny British territory, Sánchez said the end of routine border checks marked a historic moment.

"For decades, the border fence was exactly that, an open wound for the thousands of workers who crossed every day," the Socialist leader said.

"Today, we are making history, good history, because today, the last wall in continental Europe falls," he added, saying the agreement opened the doors to a "new era" of shared prosperity for the region.

The ceremony, attended by Gibraltar Chief Minister Fabian Picardo, took place after the end of border checks between Spain and the territory came into effect at midnight.