It will come into effect on December 1, just before Christmas when toys fly off shop shelves.
The protocol will prohibit the "exclusive association" of girls with toys that reproduce roles of "caregiving, domestic work or beauty" and boys with "action, physical activity or technology".
"Toys will not be presented with the express or tacit indication that they are for one gender or another nor will colour associations be made (such as pink for girls and blue for boys)," the statement added.
The agreement was signed between the government, the Spanish Association of Toy Manufacturers and Autocontrol, an independent advertising self-regulatory organisation.
In December the consumer affairs ministry staged a symbolic "strike" by toys at a Madrid park to protest against gender stereotypes.
Consumer Affairs Minister Alberto Garzon has sparked controversy in the past by calling on Spaniards to eat less meat and banning advertising for sweets aimed at children in a bid to fight obesity.
Several other European nations, including France and Britain, have in recent years adopted similar moves to end gender stereotyping in adverts for toys.