First Division Ayr United knocked Scottish Premier League side Inverness out of the Scottish Communities League Cup at Somerset Park.
Michael McGowan came close to giving the home side with several efforts in the first half.
But Eddie Malone did make the breakthrough when his low shot from McGowan's corner beat Jonny Tuffey.
Inverness thought they had levelled Ross Tokely headed into the net but the defender was flagged offside.
The result continues the Highlanders' struggling start to the season, with Terry Butcher's side having taken only one point from their opening five league matches.
McGowan curled an effort wide early on and then had a shot cleared off the line by Thomas Piermayr.
A 25-yard free-kick from the midfielder whistled past the post and a set piece from similar range at the other end allowed Aaron Doran to fire in a shot, which also went wide.
“I take full responsibility as that's my job, and I can only apologise to our fans”
Tuffey made two saves from McGowan before half-time and another after the interval.
But McGowan did have a hand in the winner as his corner fell to Malone, who rifled home from six yards.
Inverness pressed for an equaliser and Andrew Shinne volleyed wide before Richie Foran's header was blocked by Kevin Cuthbert's reaction save.
As full-time approached Tokely scrambled the ball into the net from Doran's cross but Inverness were denied extra-time by the offside flag.
Ayr United manager Brian Reid:
"I'm proud of every one of my players - a lot of them have worked shifts today and were rushing here for an early kick-off and they all deserve great credit for a great performance, all their hard work and their fitness.
"I don't think it was undeserved as we played well, passed the ball and created chances and were the better team for the first 30 minutes; Inverness then came into it and the second half was even.
"We defended magnificently, stopped them creating a lot and were still creating chances ourselves - it was a great night for Ayr and we're looking forward to the next round.
"We want to make Somerset Park a difficult place to visit - nobody's going to come down here and pick up easy points or have an easy game."
Inverness manager Terry Butcher:
"It's a real low point for me. I have no excuses - Ayr deserved to win the game, they had other chances as well as the one they scored and they fully deserved it.
"I take full responsibility as that's my job, and I can only apologise to our fans that we badly let down.
"We can't have any excuse tonight and the players have been told that - it's totally unacceptable from our point of view.
"I spoke from the start about attitude, getting the ball and passing it and winning the battle first, and Ayr were the ones who did that."
- 01 Cuthbert
- 02 Robertson
- 03 Malone
- 04 Smith
- 05 Campbell (Armstrong - 10' )
- 06 McKernan
- 07 McGowan
- 08 Geggan
- 09 Wardlaw Booked
- 10 Roberts (Tiffoney - 65' )
- 11 Moffat (Robertson - 85' )
- 20 McWilliams
- 15 Robertson
- 12 Burke
- 16 Tiffoney
- 14 Armstrong
- 12 Tuffey
- 03 Tokely
- 05 Hogg
- 16 Golobart Booked
- 19 Shinnie
- 02 Piermayr
- 07 Hayes (Ross - 22' )
- 17 Morrison (Tade - 77' Booked )
- 09 Foran
- 18 Sutherland (Shinnie - 65' )
- 23 Doran
- 01 Esson
- 10 Shinnie
- 11 Ross
- 29 Laing
- 15 Tade