WASHINGTON — President Obama has signed into law a bill that will require labeling of genetically modified ingredients for the first time.

The legislation passed by Congress two weeks ago would require most food packages to carry a text label, a symbol or an electronic code readable by smartphone that indicates whether the food contains genetically modified organisms, or GMOs.

The Agriculture Department has two years to write the rules, which will pre-empt a Vermont law that kicked in earlier this month.

Congressional passage came over the strong objections of Vermont’s congressional delegation. Sens. Bernie Sanders and Patrick Leahy and Rep. Peter Welch argued that the measure falls short, especially compared with the tougher labeling requirements in their state. While the bill gives companies the three options for labeling, the Vermont law would require items be labeled “produced with genetic engineering.”

Advocates for labeling and the food industry, which has fought Vermont’s law, have wanted to find a national solution to avoid a state-by-state patchwork of laws. While the food industry ended up supporting the final bill, many of the advocates did not, arguing that many consumers won’t be able to read electronic labels and that there aren’t enough penalties for companies that don’t comply.