Image copyright AFP Image caption Funerals for workers who perished were held throughout Thursday

Three Pakistani businessmen facing murder charges over the deaths of 264 people in a fire at their garment factory in Karachi have been bailed.

Workers were trapped inside as flames consumed the factory, in one of the worst fires in Pakistan's history.

After police registered a case against the factory owners, a court granted them "prospective bail", ensuring they cannot be arrested before 22 September.

Their lawyer told the BBC they did not believe they were responsible.

Abdul Aziz, Mohammad Arshad and Shahid Bhaila were directed to appear in court in Karachi before bail expired and the court also said the trio were not to leave the country.

World's worst workplace fires September 2012: At least 38 killed in a fire at a fireworks factory in the Indian state of Tamil Nadu

December 2011: Ninety people killed in a hospital fire in the Indian city of Calcutta

June 2010: More than 116 people killed in a fire which destroys shops and housing in Bangladesh

August 2004: A fire in a supermarket in Paraguay kills at least 364 people

December 2001: At least 280 people die in a fire in a shopping area of the Peruvian capital Lima

November 1993: More than 80 workers killed in a fire in a toy factory in southern China

May 1993: At least 188 people are killed in a fire at a Thai toy factory

March 1911: Fire in New York textile factory kills 146 In pictures: Fire aftermath Blaze was 'waiting to happen'

Their lawyer, Aamir Mansoob Qureshi, said the bail application was made at a court in the town of Larkana, 450km (300 miles) north of Karachi, the capital of Sindh province, as they feared for their lives in Karachi.

He told the BBC's Shahzeb Jillani of their sorrow at the tragedy, adding that the owners stayed at the gates as the factory burned.

He said that compensation would be made to the victims' families and that the owners would bear the medical expenses for those injured.

But he added that his clients did not believe they were responsible for the tragedy. They say they had all the compliance certificates and dispute claims that doors in the factory were locked.

The provincial industries minister has resigned.

The case has revived the debate over regulation and safety standards in Pakistan's factories.

Government officials are also being investigated for failing to enforce fire safety regulations.

Angry relatives waiting outside the Ali Enterprises factory in the north-western Baldia town area of Karachi chanted slogans against the government on Thursday.

They said the tragedy could have been prevented if the authorities had enforced the relevant safeguards.

The blaze began on Tuesday and raged for more than 15 hours.

Witnesses described how hundreds were trapped inside, because the building had metal grilles on the windows and no fire exits.

Media playback is unsupported on your device Media caption The BBC's Orla Guerin says the factory windows were barred, leaving most with no way out

Workers had little time or opportunity to escape from the four-storey building's single exit - many could do so only by jumping from those windows they could get out of. Dozens suffered broken bones or worse.

Funerals took place in Karachi and in other areas of Pakistan throughout Friday. A number of the workers came from rural Sindh and Punjab provinces.

A faulty electrical switch is thought to have caused a boiler to explode. The flames set fire to chemicals stored in the building, officials believe.

Garment factories and other plants in Pakistan require their own power sources because of an increasingly erratic national grid.

The garments industry is critical to Pakistan's frail economy. According to central bank data, it provided 7.4% of Pakistan's GDP in 2011 and employed 38% of the manufacturing sector workforce, accounting for 55.6% of total exports.