The Athletic Bilbao forward headed the ball into the net late in the game as the Black Stars edged their opponents 1-0 at the Baba Yara Stadium.
Chris Hughton’s side laboured for large spells but ultimately got the job done after being frustrated by Madagascar for much of the game.
Richard Ofori surprisingly returned to the starting line-up, having been picked ahead of Lawrence Ati Zigi, who had been Ghana’s first-choice goalkeeper since the 2022 World Cup.
The back four was made up of Alidu Seidu, Gideon Mensah, Daniel Amartey and Nicholas Opoku, while Baba Iddrisu and Abdul Salis Samed manned the midfield.
Jordan Ayew started on the left flank, with Inaki Williams shifted to the right, while Mohammed Kudus provided support for Antoine Semenyo up top.
Madagascar stunned the Black Stars with their quick start to the game and made an early impression within the opening two minutes when Rakotoharimala’s shot deflected out for a corner.
Ghana, however, responded with an attack of their own, Ayew cutting inside before firing a feeble shot into the hands of goalkeeper Adrien.
The visitors enjoyed the larger share of possession in the first half and created some good chances too, although they weren’t able to convert.
Rakotoharimala had a rare chance when he was through on goal but was forced off balance by Amartey as his resulting shot went wide.
Randriatsiferana also dribbled his way in space before shooting on goal, but Ofori reacted by saving the ball.
Ghana’s first real chance fell to Nicholas Opoku – a free header that he steered way off target. Kudus was next to set up Semenyo but the Bournemouth striker saw his shot blocked.
Madagascar were unlucky not to open the score before halftime, with Rakotoharimala’s goal ruled out for offside.
Hughton made a number of changes for the second half, with Iddrisu and Seidu making way for Majeed Ashimeeru and Denis Odoi.
Four minutes after the restart, Kudus went close with a long-range shot before Williams also fired wide from close range.
The Black Stars began to get a foothold on the game, dominating possession and finally being more purposeful upfront.
Substitute Ernest Nuamah also injected some pace into the right flank and set up Williams with a pin-point cross, but the Athletic Bilbao striker’s attempted bicycle kick didn’t come off.
Rakotoharimala nearly put Madagascar ahead against the run of play when he was left unmarked in the box, but his header struck the post.
Nuamah and Kudus combined for a great chance, but the latter’s hot was saved before agonizingly flying out of play.
With the game destined for a draw, Williams stole the headlines with a last-minute header that gave the Black Stars all three points.