A huge leap at the last put Enda Bolger's stable star into contention alongside 5-4 favourite Gitane Du Berlais and 25-1 chance Smashing.
Gilgamboa then held off The Tullow Tank (9-1), who came from nowhere to finish second by just half a length.
Smashing edged out Gitane Du Berlais, with Ruby Walsh riding, for third.
McCoy announced he would be retiring this year after claiming his 200th winner of the season at Newbury in February.
After ruling out riding at the Punchestown Festival, his weekend appearance in County Meath looks set to be his last as a jockey on Irish soil.
On Monday, the 40-year-old will partner Cantlow in his final Irish Grand National.
McCoy said: "Fair play to Enda. I am delighted to ride a big winner for him before I retire."
Bolger was pleased to win for the first time with McCoy on board one of his horses.
He said: "It is great to win a race like this and to have that man on top."
McCoy was similarly brilliant earlier in the afternoon when Sir Scorpion justified 6-4 favouritism in the Gleesons Butchers Novice Handicap Hurdle.
Retiring 19-time champion jockey AP McCoy pulled off a superb victory on 7-1 shot Gilgamboa in a pulsating Ryanair Gold Cup at Fairyhouse.