A pitcher will take an L unless their team can tie or take the lead after they leave. I.e a pitcher leaves losing 4-1, his team ties it, then loses, he won't take the L. Same scenario and the opposing team keeps piling on runs and the losing team keeps scoring but at no point ties or takes the lead, the pitcher will take the loss.
XI Wiki



