KABUL (Reuters) - Thousands of Afghan families are fleeing Pakistan to escape harassment after a deadly Taliban attack on a school in Peshawar in December, the head of the International Organization for Migration (IOM) in Afghanistan said on Saturday.

More than 22,000 undocumented Afghans flocked across the border at Torkham in January, more than twice the figure for the whole of 2014, said Richard Danzinger, the IOM's mission chief in Afghanistan.

Almost 1,500 others were deported in the same month, double the number of deportees in December.

"It all started with the attack on the school in Peshawar," Danzinger told Reuters. "When something horrible happens, people start taking it out on foreigners."

Taliban militants attacked a school in the northwestern Pakistani city of Peshawar in December, killing more than 130 children and prompting Pakistan to step up operations against insurgent hideouts along the border with Afghanistan.

Cooperation between Afghan and Pakistani security forces has also improved since the attack and led to the arrest of suspects in Afghanistan, where officials believe it was planned by the Pakistani Taliban.

Afghans living in Pakistan, however, face a backlash and are reporting incidents of harassment, such as raids on their homes and police coercion, according to the IOM and other officials.

Most of the Afghan families had settled in Pakistan decades earlier, Danzinger said, and had nowhere to go once they returned.

"Their lives are in Pakistan," he said, adding it was unclear how long they would remain in Afghanistan.

The flow of undocumented returnees has increased steadily in January, rising from around 350 in the first week to around 1,400 in the final week of the month.

"It is very difficult to predict at the moment," Danzinger said of the upward trend. "We've not seen it slow down, let's put it that way."

The unexpected arrival of thousands has put pressure on Afghanistan's limited resources and only the most vulnerable are being given assistance.

About 10 percent of those arriving so far have access to assistance and the IOM had been forced to pull some of its resources away from the western border with Iran to cope, Danzinger said.

The IOM says it needs another $1.6 million in funds for 2015 to cope.

(Editing by Paul Tait)