WASHINGTON — With the most extensive food safety regulations in history set to take effect soon, state agriculture officials across the country are preparing to enforce the federal law, but say their ability to inspect farms and enforce the new standards depends on the receipt of promised federal funds.

The law – which Congress approved in 2011 following several high-profile outbreaks of foodborne illnesses, linked to contaminated spinach, tomatoes and peanut products – comes at a time when demand for fresh vegetables is increasing. And it marks a shift in focus for the nation’s food safety system, from containing foodborne illnesses once they occur to preventing those outbreaks in the first place.

It gives the U.S. Food and Drug Administration new authority to regulate the production of fresh fruit and vegetables. It also imposes the same food safety standards on imports as it does on domestic foods, and includes provisions to create a more integrated food safety system across all levels of government – federal, state and local.

The law, known as the FDA Food Safety Modernization Act and set to take effect gradually through 2020, applies to all farms except meat, poultry and egg producers. Farms that have less than $500,000 in annual sales are not covered, although their buyers may insist that they adhere to the standards.

And the FDA reserves a key role for states in ensuring that farmers comply with new standards for water quality, sanitation, the handling and composition of compost, and worker training and hygiene. That means on-site inspections and laboratory testing water used in irrigation and soil used in planting.

“State agriculture and public health personnel are the ones who have built relationships with and knowledge of local farming communities and practices and can often deliver oversight most efficiently,” top FDA officials wrote last month. “But almost all states will have to build produce safety programs largely or completely from scratch. We want to rely on them, not only to deliver education and technical assistance, but also to provide ongoing compliance support and oversight.”

States that produce little of the fruit and vegetables covered by the law – Montana, North Dakota and Wyoming – are expected to opt out, leaving that work to federal authorities.