Irish Premiership: Linfield 3-2 Ballymena
Title hopefuls Linfield recovered from an early Ballymena goal to clinch the win which leaves them level on points with Premiership leaders Portadown.
Ballymena took an early lead through defender Johnny Taylor's header.
Hegarty nodded in Linfield's equaliser and the Blues defender scored again to edge the hosts in front.
Blues top scorer Aaron Burns poked in before half-time for 3-1 but Taylor revived Ballymena's hopes by heading in midway through the second half.
Having lost their last home match to Glenavon, Linfield were anxious to get it right against a Ballymena side which had made an encouraging start to the league campaign.
Glenn Ferguson's side, who had gone into the Windsor Park clash level on points with Linfield, hit the front in the ninth minute.
Neal Gawley sent over a corner and former Glentoran man Taylor scored with a header.
Hegarty got Warren Feeney's Blues level in the 21st minute after United keeper Dwayne Nelson had failed to claim a Neal Gawley corner.
Five minutes later Linfield were ahead as Hegarty snapped up the chance when Niall Quinn's free-kick had come off an upright.
Burns made it 3-1 in the 38th minute, beating a defender and slotting past Nelson.
At that stage, Linfield were looking comfortable but United were right back in contention when Taylor's 65th-minute leader was adjudged to have crossed the line.
Nervy Linfield had a lot of defending to do as Ballymena pressed for a late equaliser.
The visitors almost got that goal deep into stoppage-time when keeper Jonathan Tuffey was forced into a fine save by David Cushley.