Spanish police officers guarding the border with Morocco in the Spanish North African enclave of Melilla stopped an attacker shouting "Allah is great" on at 7:35 a.m. Tuesday morning, news agency EFE reported.

The man was wielding a large knife.

As the man, dressed in a blue t-shirt, entered the area, he was surrounded by several officers, one of whom quickly had the bright idea of disabling the attacker with a chunk of traffic barrier.

He picked up the heavy plastic object and threw it at the attacker's head, knocking him on to the floor. His police colleagues jumped on the man and arrested him.

One of those police officers received a small cut to his finger.

Spain's Home Secretary, Juan Ignacio Zoído, confirmed on Twitter that: "The police have arrested a man who attacked officers at the border post in Beni Enzar with a knife, one of them was lightly injured".

He described the incident as "serious" and thanked officers for their "quick, coordinated, professional actions".

The event is not being treated as a terrorist attack.