Hamilton overcame Berwick in an enthralling encounter in the CIS Insurance Cup second round.
Berwick took the lead through an Iain Diack shot following a quick free-kick.
Hamilton levelled when David Winters rose to head in Tony Stevenson's corner at the far post.
Hamilton's Brian Wake rifled in a superb pass from Tom Parratt, who then netted a 65th minute own-goal, but with 15 minutes to go Wake steered home James McCarthy's pass to end the game.
Berwick: O'Connor, Noble, Horn, Smith, Bolochoweckyj, Greenhill (Gemmill 70), McLeish, Diack, Wood, Swanson (Thomson 85), Lennox (McMullan 80).
Subs Not Used: Stevenson, Flockhart.
Goals: Diack 10, Parratt 65 og.
Hamilton: McArthur, Halliwell, Parratt, Gibson, Swailes, Elebert, Stevenson (Neil 39), McCarthy, Offiong (Wake 33), Winters, Gilhaney (McLeod 88).
Subs Not Used: Easton, Cerny.
Goals: Winters 15, Wake 55, 75.
Ref: D Somers