The new food recall procedure was published on the agency's website on Monday and will come into effect on 1 August.
The law, while only enforceable within the Shanghai FDA's jurisdiction, is a sign of increasing government interest in consumer protection and rights.
Chinese food authorities increasingly issue food safety warnings to the public and also fine food companies deemed to have placed consumers at risk with poor quality food or drink products. However these fines tend to be retroactive, based on the damage or illness caused to consumers.
Shanghai's new law seeks to place greater emphasis on prevention and control of food-related disease.
It requires food manufacturers and distributors to report faulty or poor quality food products to the government and consumers, and recall the product from store shelves within a timeframe dependant on the level of risk.
For example, for A-level products, or those that have already caused serious harm or even death, the manufacturer must report the problem to the authorities and issue a full recall within 72 hours.
For B-level products that cause temporary harm or could lead to non-fatal illness, companies are required to recall the products within seven days.
For C-level products that do not pose an obvious health risk, manufacturers only need to take products back from retailers.
"If an enterprise does not recall voluntarily or their recalling is not effective the government still imposes punishment after recalling," Gu Zhenhua, director of SFDA's inspection department, told the Shanghai Daily.
"We give lenient punishment if they perform well; otherwise the punishment will be severe."
Fines will be up to five times the value of income from the products concerned, although this does not include recalled products. Companies that fail to recall their products can have their licences withdrawn.
Feng Zheng, a lawyer specializing in food law at Lovells' Shanghai office, said the new law reflected growing government interest in food safety.
"People have been talking about implementing a recall system in national law for about two years," she told AP-Foodtechnology.com.
"I'm happy to see that the Shanghai government took the lead. But whether it brings real improvements in food safety remains to be seen."
A number of incidents of spoiled food have been reported around China in recent months, and it is not just domestic companies at fault. In May, Carrefour's Shanghai stores were fined by the Shanghai food authorities for selling expired pork products.
Last week the state FDA issued a warning about milk powder for the elderly found to have almost no protein. It comes two years after fake milk formula led to the deaths of at least 13 babies.
So far, the agency has not had any complaints from consumers about the Dongfang brand milk, which is produced jointly by two companies in Inner Mongolia. But it does not have regulations in place allowing it to recall the product.
Under the new law in Shanghai, Zheng noted that it is not clear whether the Shanghai FDA will be able to enforce the rule on businesses residing outside its jurisdiction.
"Many food products [sold in Shanghai] come from other places, especially agricultural produce, so I'm not sure how they will implement the law," she said.
The country's principal cities, such as Beijing or Guangzhou, could follow Shanghai's lead, added Zheng, although it is likely that they will wait to see how Shanghai's new law works before implementing it elsewhere.
"Shanghai is a more advanced city and the government is more open-minded. They may want to take the initiative to show how modern they are."
It is also thought that Beijing may have requested a trial of the law in Shanghai before bringing it in nationwide, although Ms Wu, head of the policy and regulations department in the state Food and Drug Administration did not confirm this speculation.
Instead, she told AP-Foodtechnology.com: "We are researching foreign countries' food recall systems."
The Shanghai FDA is still drawing up standards to define the grades of risk from poor quality food and required timeframe for recall. They are expected to provide training and explanations of the rule to local food firms before the law enters into force in August.