It was United who looked set to progress in the competition when Danny Grainger opened the scoring and provided the visitors with a first-half lead.
But two goals from Swailes within 10 minutes of the restart put Accies in the driving seat and they held on to ensure their name would be in the hat for Sunday’s last-eight draw.
Hamilton boss Billy Reid claimed in his programme notes that he had “no axe to grind” with Craig Levein after a war of words broke out between both managers after their last meeting, with Levein accusing Accies of being too negative and Reid retaliating.
But there was no doubting the strong rivalry between both teams, after Hamilton claimed the honours here on the opening day of the season and then earned a point in that last clash at Tannadice.
Reid was determined to see his side maintain their impressive record, while the visitors were equally keen to record their first win of the season over their hosts at New Douglas Park on Saturday.
Rocco Quinn and Kenny Deuchar made their debuts for Accies as Reid made four changes from the side who defeated Hearts last week but United were without their own new signings Paul Caddis and James Wesolowski, who were cup-tied and lacking match fitness respectively.
The first chance of the game fell to Hamilton when the ball broke to James McCarthy and he drew gasps from the crowd with a shot which was deflected across the face of goal and narrowly wide.
At the other end, Warren Feeney did well to skip past Alex Neil but was denied the shot on goal by goalkeeper Tomas Cerny, who raced off his line to block. Grainger then blasted well over from the corner.
Accies were threatening again when Brian Easton sent his corner into a packed box which was met by the head of Swailes at the back post. He nodded across goal to James Gibson but his shot was blocked by the United defence.
Quinn then did well to race past several United players into the box before driving just over the crossbar as the home side pressed for the opener.
Instead, it was United who surged into the lead after 34 minutes. Prince Buaben was fouled on the edge of the box and Grainger stepped up for the free-kick to send a powerful, low shot under the Accies wall and into the bottom corner of the net.
Incredibly, it was the first goal conceded by Cerny in 495 minutes of football – since their 1-0 defeat at St Mirren in December.
United could have added to their lead before the break when Craig Conway’s flag-kick was knocked into the path of Feeney by Garry Kenneth and he nodded inches wide of the upright.
Hamilton must have enjoyed an inspirational pep-talk at half-time because they were back on level terms just a minute after the restart.
A burst of pace down the left flank took McCarthy past Sean Dillon before picking out Swailes eight yards out to rifle home in plenty of space.
Clearly boosted by the goal, the home side took the lead with just 55 minutes on the clock as Swailes claimed his second of the day.
Easton was the provider with a great corner to the back post where Swailes was waiting to bullet a header past the helpless Lukas Zaluska.
The United goalkeeper was then called into action again to block a point-blank shot from substitute Richard Offiong as Accies attempted to crank up the pressure.
With 15 minutes to go, Francisco Sandaza and Danny Swanson were both thrown into the action as United desperately tried to haul themselves back into the tie.
They pushed forward in numbers and Lee Wilkie saw his close-range header blocked by Cerny from a Swanson cross just a few yards out in the final minutes.
Even Zaluska came forward for an injury-time corner but despite those last-ditch efforts, Accies did well to hold onto their narrow lead and extend their run in the tournament.