IDOMENI, Greece (Reuters) - Hundreds of Moroccans, Algerians and Pakistanis tried to storm the border between Greece and Macedonia on Thursday, tearing down part of the barbed wire fence at the crossing and demanding to be allowed to carry on into northern Europe.

They were among about 1,500 migrants who have been stranded near Greece's northern border town of Idomeni after Europe decided to filter migrants, allowing only those fleeing conflict in Syria, Afghanistan and Iraq to cross into the Balkans.

Some threw stones at police while others fell to their knees shouting, "We want to go to Germany!"

A few ran across into Macedonia but were quickly detained by police. Police in riot gear guarded a gap where migrants had torn down about 30-40 meters of fence, and a Reuters photographer saw riot police armed with assault rifles.

More than 800,000 refugees and migrants from the Middle East, Africa and Asia have arrived in Europe by sea so far this year, most through the Greek islands, seeking a better life in wealthier European countries such as Germany.

Balkan countries have clamped down at their borders recently to stem the largely unchecked stream of people, leaving tens of thousands stranded in Macedonia, Serbia and Croatia.

The United Nations has condemned the new restrictions on travel based on nationality.

So far, only 148 refugees have been relocated from Italy and Greece to other EU countries under a plan for transferring 160,000 agreed by EU leaders in September.

(Reporting by Yannis Behrakis; Writing by Karolina Tagaris; Editing by Louise Ireland)