The Crystal Palace striker scored his 19th goal for the World Cup-bound Black Stars, equalling the record held by his father to become Ghana’s all-time top scorer.
Although Pele scored those goals in 73 games, his son has done so after making 80 appearances for the former African champions, and he remains 32 goals behind all-time Ghana top scorer Asamoah Gyan.
Meanwhile, Miki Yamane broke the deadlock – with an assist from Ritsu Doan – in the 29th minute as Japan and the West Africans clashed in what was their seventh meeting across all competitions.
Assisted by Christopher Antwi-Adjei, Ayew equalised in the 44th minute before the hosts quickly regained their lead in the first minute of added time of the first half when Kaoru Mitoma fired past Lawrence Ati-Zigi in Ghana’s goal.
Mitoma played a key role in Japan’s third goal when he provided an assist for Takefusa Kubo, who scored in the 73rd minute.
Daizen Maeda, a second-half substitute, added the fourth goal for the Far East nation when he struck in the 82nd minute as Junya Ito provided the assist.
The Black Stars are taking part in the tournament – which also contains Chile and Tunisia – as they prepare for the November-December World Cup in Qatar.
In the second semi-final, Tunisia emerged 2-0 winners against Chile as the tournament celebrates its 21st anniversary.
The Carthage Eagles’ goals were scored by Ali Abdi, in the 41st minute, and Issam Jebali in the 89th minute.
Chile and Ghana will face off on June 14 as they compete for bronze, while Japan take on Tunisia on the same day in the final.