Lucas had given Hamilton a first-half lead before Michael Gardyne and Boyce came to County’s rescue, while the hosts lost Filip Kiss to a straight red card eight minutes from time.
During a bright opening 20 minutes in Dingwall, County’s Craig Curran had an early effort saved by Michael McGovern while Jesus García Tena went close for Hamilton.
Garcia Tena came close again, forcing a good save from Antonio Reguero, while Gardyne flashed a shot across the face of goal.
And it was in-form Accies who opened the scoring on 27 when Ali Crawford’s corner was headed into the bottom right-hand corner of the net by Brazilian defender Lucas.
As third-from-bottom County tried to get back into the game before the break, Gardyne fired wide from 14 yards.
And the equaliser duly arrived via the feet of Gardyne, 12 minutes into the second half, when the striker located the bottom left-hand corner from 18 yards after latching on to a loose ball following a corner.
Hamilton striker Darian MacKinnon had a 72nd minute header saved before County were reduced to 10 men when Kiss was dismissed for an off-the-ball incident.
However, three minutes later the depleted hosts went ahead as Boyce was quickest to react, as he lashed home from close range leaving visiting keeper McGovern no chance.
County survived a scare deep into injury time when Crawford rattled the bar from 20 yards but the hosts held on to collect their most important three points of the season.
The victory, and Motherwell’s 2-1 defeat at St Mirren, secured County’s top-flight status for next season while condemning Well to a two-legged play-off against Queen of the South, Hibernian or Rangers.