Selangor is offering an amnesty to 3,500 illegal factories after finding they had attracted foreign investment and were contributing hundreds of millions dollars to the economy.

The factories in Selangor failed to obtain licenses for reasons including pollution standards, but they provided 150,000 jobs and contributed RM2 billion to the state's economy yearly, an official was quoted as saying in the New Straits Times newspaper.

Many had also attracted foreign investment and were involved in hi-tech manufacturing, it said.

"To shut them down would cause hardship to workers and lead to a host of other social problems," Mohamad Mokhtar Ahmad Dahlan, chair of Selangor's housing committee, was quoted as saying.

Mokhtar said the state government decided to give the factories until the end of the year to legitimise their operations after considering their contributions to the economy.

Government agencies, including the environment department, would help the factories to revamp their operations.

"If their operations do not pose any danger to the environment, there should be no reason for permits to be withheld," he said, warning they would be shut down if they continued to flout the law.

Selangor is a key state for manufacturing in Malaysia and houses a number of industrial estates.