Ayew replaced midfielder Iddrisu Baba in the 82nd minute as the Black Stars defeated the 139th-ranked country by a single goal.
Since his debut in 2007, Ayew has made 109 appearances for Ghana, tying Gyan, who played his 109th match in 2019.
Andre has scored 23 goals, 10 of which have come in the Africa Cup of Nations, making him Ghana’s leading scorer in the competition.
Fatawu Issahaku scored in the 35th minute with a lovely strike. The winger found space on the right and beat the goalkeeper with great effort.
Despite numerous chances, Ghana was unable to score a second goal as the game ended 1-0 in Lorca, Spain.
Black Stars will play another friendly against Switzerland on November 17 before beginning their World Cup campaign on November 24 against Portugal.
They will then play South Korea and Uruguay to complete the group stage.