As many as 25 migrants have drowned in the Mediterranean trying to reach Europe after a Libyan coastguard speedboat attacked their dinghy off the coast of the north African nation.

A rescue boat from the German NGO Sea-Watch went to help the distressed vessel in the early hours of the morning, AFP reported.

The stranded dinghy, which had remained intact, was found just beyond Libyan territorial waters north of the port of Sabrata, a pivotal people-trafficking hub on the Libyan coast.

As the Sea-Watch rescue vessel attended the scene, a speedboat bearing the Libyan coastguard markings arrived and tried to steal its engine.

Spokesman Ruben Neugebauer was quoted as saying the men beat some of the migrants with sticks, causing chaos. In the panic one side of the boat deflated and most of the passengers ended up falling into the waters below.

The coastguard vessel then fled the scene, although it was not clear if the attackers had stolen the speedboat or whether they were coastguard workers.

The rescue workers were able to save 120 people from the Mediterranean, recovering four corpses. It was estimated that between 15 and 25 of the people who had been on the board were unaccounted for as other bodies were seen floating out of reach.

Sea-Watch described its own rescue vessels as having been "hassled in an aggressive way". The NGO said the attackers were "preventing our crew from providing life vests and medical aid to the people in need. All of these deaths could have been avoided but for this intervention."

A Libyan coastguard spokesman was quoted by the AFP as saying he had "not not been unaware of the incident". The EU is currently enacting plans to begin a training initiative at the end of this month vetting of around 80 Libyan coastguard staff. They are due to bolster Libyan efforts to stem the number of migrants attempting to reach Europe over the Mediterranean from Libya.