M&S launched legal action against the German discount store in April last year, accusing Aldi of copying the design of its Colin the Caterpillar cake in a bid to force Aldi to take its Cuthbert the Caterpillar cake off the shelves and agree not to sell anything resembling it in the future.
Both supermarket giants have confirmed a deal has been struck.
In May, Aldi started selling its caterpillar cake again after making changes to its design.
Deputy Master Timothy John Bowles signed off an agreement in a consent order filed at the High Court on Thursday.
The order allowed the claim to be withdrawn and said the retailers had reached a “confidential agreement” in November.