Ireland narrowly avoids snap election