Next-to-last West Indies ended the World Cup with two victories — from their first and last games — and moved level on five points with South Africa, which still has a match to play against Australia.
It was a disappointing tournament for the Windies.
The Windies won the toss and made 311-6 on a good batting strip, with Evin Lewis (58) and Hope (77) scoring half-centuries at the top of the order.
Nicholas Pooran (58 off 43) and Jason Holder (45 off 34, including four sixes) teed off near the end, helping the team rack up 111 runs off the last 10 overs that ultimately proved the difference.
Afghanistan was on track to chase down the target when Gayle, 39, trapped Ikram — at 18, less than half his age — leg before wicket. Two more wickets were lost in the next 13 balls as Afghanistan slipped from 189-2 to 201-5.
West Indies failed to kick on from a seven-wicket win in its opening game against Pakistan, which was skittled out for 105 in 21.4 overs.
There were narrow losses to Australia and New Zealand, but their batsmen never hit top form. Gayle, the talisman at the top of the order, made only two half-centuries in nine games.
All-rounder Carlos Brathwaite wants his team to follow the model of England and rebuild the team for the next World Cup in India.
"As a team, we need to regroup. We have some time off, some aching bodies will get time to recuperate and then it's about finding ways and combinations to compete and win series," Brathwaite said.
"Hopefully we can take that winning mentality into the next World Cup. If you look at 2015 and what England did after the World Cup, they have built straight up to the 2019 World Cup and it's paying dividends."
"I don't know off the field what the plans are for the 2023 World Cup but I think it's something we need to look at and build towards that."