Philip Roberts scored a stoppage time goal to earn Inverness a Scottish Cup draw with Highland rivals Ross County.
Billy McKay volleyed the visitors ahead on 30 minutes, while Rocco Quinn levelled with a glorious 20-yard shot.
A McKay shot deflected in off Foran before a strike from Iain Vigurs spun off a defender to loop into the net.
A 93rd-minute Richard Brittain free-kick appeared to have won the game for the hosts but Roberts had the last say from close range in a frantic finale.
The teams will meet again on 11 December to settle the fourth round tie.
County did most of the pressing in a scrappy opening spell but were limited to wild shots from Stuart Kettlewell and Richard Brittain and an awkward prod from Sam Morrow that bobbled wide.
Almost half an hour had passed before Inverness threatened, with Mark Brown making a smart save from Aaron Doran's fierce strike, following a good headed flick-on from Foran.
Soon after, Caley Thistle were ahead thanks to McKay's 10th goal of the season.
Doran clipped an angled free-kick into the penalty box and Foran headed the ball back across goal for the Northern Irish striker to crack in a lovely volley from 14 yards, that went in off the post.
County responded with Gary Glen firing a dangerous ball across goal but Kettlewell was stretching to reach it at the back post and could not steer the ball on target.
And the first half finished with a flurry of activity, as Brittain curled a free-kick against Reguero's near post from a tight angle
The ball fell to Vigurs in a packed penalty area and the County midfielder's shot was cleared off the line by Foran.
The visitors immediately launched a swift counter-attack and when Doran was tackled the ball broke to McKay, who went wide to round Mark Brown but the striker's shot was blocked by a defender in blue.
From the resulting corner, Foran rose well to connect with a header but sent the ball narrowly wide of the unguarded back post.
The second half was just a few minutes old when County drew level with a goal of the highest quality.
Full-back Mihael Kovacevic galloped forward to the right edge of the penalty area and laid the ball off for Quinn, who looped a curling, first-time strike over Reguero and into the top corner of the net.
Buoyed by such a fine strike, the home side had their tails up and Inverness were pinned back, making a series of last-ditch challenges in the final third of the pitch.
Kettlewell did manage to get in behind the visiting defence but steered his header wide from a promising position.
Reguero then had to smother a low drive from Brittain as the one-way traffic continued.
Having weathered the County storm, Inverness rediscovered some of the form that has made them the Scottish Premier League's top scoring team as a smart turn and shot from Andrew Shinnie drew a good diving save from Brown.
But when Caley Thistle's second goal arrived it owed much to a huge slice of fortune.
Shinnie worked the ball to McKay for the striker to set his sights for a curling shot from 20 yards.
McKay's effort was sailing wide before it struck the face of Foran, who had strayed a yard offside, and the deflection completely wrong-footed Brown as the ball bounced into the middle of the net..
With five minutes remaining, the game was level again and there was another element of luck involved as Vigurs drove forward from midfield and unleashed a shot that took a wicked spin off defender David Raven and away from the grasping fingertips of Reguero.
Stoppage time was running out when Brittain lashed in a low, curling free-kick from the left and it nicked the shoulder of Scott Boyd before evading everyone else and nestling in the net.
With the home support busy celebrating, Inverness midfielder Owain Tudor-Jones thundered in shot from 40 yards that was awkwardly patted away by Brown.
And from the corner, Josh Meekings' header was poked towards goal by Foran and struck the knees of Roberts from close range to level an amazing game for a third time.