Longford went ahead when they were awarded a penalty by referee Robert Hennessey, just before the break, which was scored by David O’Sullivan.
Longford then surged ahead. Mark Rossiter scored from 35 yards, and then Gary Shaw beat Ryan McBride to a free kick to head home.
Shaw was then fouled, leading to another penalty. Patrick Sullivan scored from the spot.
Ronan Curtis and Rob Cornwall got late consolation goals for City.