The Triarii was the third standard line of infantry of the Roman Republic’s army. When suffering defeat, the first and second lines, the Hastati and Principes, fell back on the Triarii to attempt to reform the line and allow for a counter attack or withdrawal of the other lines. The Triarii were the veterans of the Roman army, making them perfectly suited for reinforcing the two front lines of the formation.
When the Principes and Hastati of Republican army were rearmed with javelins, the Triarii retained their long spears and scuta and continued to fight as a phalanx. If the initial attacks of the javelin- and sword- armed troops could not break an enemy, the Triarii served as a strong point around which the army would regroup (in the same manner as in much later centuries squares of musketmen were to provide a defensive screen for reforming cavalrymen). They also were responsible for holding off cavalry charges with their spears.