Two protesters died on Monday as rallies in Pakistan over an anti-Islam film intensified, with thousands taking to the streets, burning US flags and an effigy of US President Barack Obama.

About 800 people demonstrated in the northwestern town of Warai, in Upper Dir district, setting fire to a magistrate's house and the local press club before a protester was killed in an exchange of gunfire with police.

Another demonstrator died on Monday afternoon after being shot in the head during clashes with police near the US consulate in Karachi on Sunday, a hospital official said.

Up to 3,000 university students, teachers and employees marched in Peshawar, the main city of the militant-plagued northwest, chanting anti-US slogans and demanding a ban on the "Innocence of Muslims" movie.

The American embassy in Islamabad was closed on Monday because of the risk of demonstrations near the mission, and diplomats have been banned from all but essential travel throughout the country.

"One person was killed and two injured during exchange of fire between the police and protesters," Mohammad Irshad, a senior local government official in Upper Dir, told AFP.

Officers baton-charged protesters, who were chanting anti-US slogans, and fired tear gas to try to disperse them, Irshad said.

They also fired live rounds into the air, prompting the demonstrators to return fire, he said, although it was unclear who fired the fatal shot.

Ihsanullah Khan, police chief for Upper Dir, which is adjacent to a former Taliban stronghold crushed in 2009, said 22 protesters had been arrested and the situation was under control.

In the border town of Chaman, in southwestern Baluchistan province, where trucks supplying troops with the US-led NATO force in Afghanistan cross the frontier, about 500 students demonstrated, burning an effigy of Obama.

Hundreds of students protested in Quetta, the capital of Baluchistan, with caricatures of Obama placed on a donkey as a gesture of humiliation.

At another protest in Peshawar, some 350 activists from Islami Jamiat-e-Talaba blocked a main road by setting fire to tyres and burning a US flag, an AFP reporter said.

In the port city of Karachi, up to 100 youths from JI rallied, trying to reach the American consulate before being dispersed by police with tear gas.

An AFP reporter saw heavy containers and barbed wire positioned across roads leading to the consulate to stop vehicles and individuals.

A total of 19 people have now died in violence linked to the film, including four Americans killed in the Libyan city of Benghazi.