COPENHAGEN (Reuters) - Danish police closed a motorway and rail links with Germany on Wednesday in a bid to stem the flow of refugees heading north to Sweden, as Europe's migrant crisis spreads northward.

The motorway, a vital traffic artery for people and goods between the two countries, was closed when some 300 refugees, including children, began walking on it. Police tried to persuade them to leave but appeared reluctant to use force, witnesses said.

"We are trying to talk to them and tell them that it is a really bad idea to walk on the motorway," a police spokeswoman said.

Police also asked the state-owned railway operator to stop all trains between Germany and Denmark until further notice.

Vast numbers of people, many fleeing war and Islamic State in Syria, are trying to reach safety in EU countries willing to have them. Most have headed to Germany, but Sweden is also a favorite destination. Both countries have more generous policies for refugees than their EU neighbors.

Denmark is part of the EU's Schengen zone, where borders are meant to be open to allow free movement. When asked by Reuters whether blocking the road and rail links meant breaking with the Schengen system, a police spokesman he did not think so as he expected to traffic to start moving again soon, although he could not say when.

At Rodby, where train ferries arrive in Denmark from Germany, two trains carrying about 240 people were stopped by police. Refugees on board were refusing to leave the train, police said.

Around 100 foreign passengers left a train that was still on a ferry and were transferred to a school for registration.

Many refugees are reluctant to register in Denmark, where a centre-right government has cut benefits.

"We know that many of them want to go to Sweden, but naturally we cannot let that happen," police spokesman Carsten Andersen said. "So right now, we have asked them to start a dialogue. We are waiting patiently for some of them to agree to that and stick their heads out of the trains."

Story continues

Justice Minister Soren said he was cutting short a trip to the United States to return to Denmark.

"For security reasons, the police, in collaboration with German authorities, decided that for the near future no traveler's from Syria, Iraq, etcetera will arrive in Denmark by ferry to Rodby," police said in a statement.

(Reporting by Teis Jensen, additional reporting by Ole Mikkelsen and Alexander Tange; Editing by Robin Pomeroy)