"The absolute ban on advertising is unduly restrictive and is more than necessary to further the avowed governmental interest of promoting the health of infants and young children," the court said in its ruling.
The ban, which is included in the government's 1986 "Milk Code," took effect last year, affecting an industry worth millions of dollars.
The World Health Organisation (WHO) and the United Nation's children's agency (UNICEF) supported the ban, but the milk companies' Pharmaceutical and Health Care Association of the Philippines had challenged its legality in court.
UNICEF spokesman in Manila, Dale Rutstein, said his organisation was disappointed by the decision.
"We feel that advertising by companies that produce infant formula make false claims about their products that convince and brainwash mothers and fathers," he said.
The court's decision comes as the health department was trying to extend the ban to products for two-year-olds, in line with an international code created by the WHO and UNICEF about 25 years ago.
WHO regional director Shigeru Omi has said failure to breastfeed leads to the deaths of 16,000 children in the Philippines each year.
Omi and other health officials have said breast milk is far healthier and more economical than infant formula, which they said was often improperly prepared in non-sterile conditions.