A wonder strike by Stephen Lowry on 85 minutes got title-chasing Linfield out of jail this afternoon.
The three points at Ferney Park now leaves them just four points behind leaders Crusaders.
The home side started brightly and created a number of good chances early on.
Ballinamallard took the lead on the half-hour mark when Ryan Curran drilled a low shot into the corner past Gareth Deane from 20 yards.
Andy Waterworth almost levelled two minutes later when he was put through on the right, but keeper Richard Brush pushed the ball away to safety.
Linfield should have been on level terms when Niall Quinn headed over with the goal at his mercy after good work by Mark Stafford.
Within five minutes of the restart the visitors were on level terms.
Waterworth chased a ball to the byline and pulled it back across goal. Colm McLaughlin seemed to have it covered, but let the ball slip through his legs and substitute Aaron Burns was on hand to tap home from close range.
The title chasers piled on the pressure as Quinn saw his back-post header cleared off the line by Ryan McConnell and Kirk Millar’s header across the face of the goal was just wide.
On 81 minutes, a Stafford mistake allowed Jason McCartney through on keeper Deane. The Ballinamallard wingman chipped to the open goal as Deane raced off his line, only to see his effort come off the top of the crossbar.
Then, after sustained pressure, the ball was only half cleared by the home defence on 85 minutes. It fell perfectly for Lowry to hit a brilliant strike into the top corner from 25 yards.
Linfield manager David Healey admitted his side got out of jail with the late goal.
He felt the McCartney miss was a big let-off for the Blues and said they almost got hit by a sucker-punch.
“I knew how difficult it would be coming down here,” said Healy. “I warned the players that you don’t get any free points down here.
“It was the same today.”
Asked whether the title race was now open after Cruasders’ loss, Healy felt they were still in the driving seat.
Gavin Dykes, the Ballinamallard manager, said his side couldn’t afford to miss good chances.
“We had three or four chances to clear our lines for the goal,” said Dykes. “But in fairness it was a great strike.
“I’m annoyed because in the first half we did well, I felt we deserved something out of the game.”
BALLINAMALLARD UNITED: Brush, McLaughlin, Taheny (Mullan, 87), McGinty, Armstrong (McCartney, 57), Lafferty, McConnell, Mayse, McCann, Curran. Subs (not used): McGrath, Frempong, McCartney, Morris, Mullan.
LINFIELD: Deane, Stafford, Haughey, Callacher, Waterworth, Lowry, Millar (Carson, 69), Clarke, Mulgrew, Quinn, Smyth (Burns, 45). Subs (not used): Burns, Ward, Casement, Glendinning, Carson.
Referee: Evan Boyce.