A refugee crisis is looming on the Libyan-Tunisian border as thousands of foreign workers try to escape the fighting with concern also growing over how long food stocks inside Libya can last, aid agencies have warned.

The UN high commission for refugees said 140,000 people have now fled Libya – half of them crossing into Egypt and half into Tunisia.

Most refugees are Egyptians who had been working there. On the Egyptian border they have dispersed to their home towns and villages. On the Tunisian side, local authorities' efforts to deal with them are being overwhelmed as between 1,000 and 2,000 people cross every hour, according to aid workers there.

Tunisia has tried to stem the flow to clear more space for tents and stock up on food supplies, prompting a backlog of around 20,000 refugees on the Libyan side waiting to get through, with rising fears for their wellbeing as they have little food and are left exposed at night to the cold.

Josette Sheeran, executive director of the World Food Programme (WFP) who visited the Libyan-Tunisian border on Tuesday, said the local Red Crescent organisations and the revolutionary committees set up during the Tunisian uprising had been doing an "excellent" job providing food and shelter, but added that "the system is now under severe stress".

"We are not seeing a diminishing of the numbers of people crossing the border, and we're very worried about people trapped on the Libyan side of the border," Sheeran told the Guardian in a telephone interview.

The WFP has flown in 80 tonnes of high-energy biscuits to give refugees as they arrive. They are often exhausted and starving after a long trek to safety.

Meanwhile, Sheeran said, there was concern about the situation inside Libya, which relies on imports for more than 90% of its food. Those imports have been badly hit by the turmoil inside the country.

She said she was particularly worried about the situation in Zawiya, which is held by rebels but surrounded by pro-Gaddafi forces.

"There have been some reports of a breakdown in the food supply in Zawiya," she said. "We are very concerned that food should not be used as a weapon, and it's very important that we watch this situation."

Elsewhere, Sheeran said, the situation appeared to vary from town to town. There seemed to be food in the shops but it was unclear whether there were sufficient stocks to replenish those supplies when they are exhausted.

The WFP will dispatch a team to Benghazi on Wednesday to check if the port is safe for food deliveries and to inspect the food supply situation. WFP planners were trying to assess what corridors might be used from Tunisia and Egypt for the delivery of aid if a food emergency develops in Libya.