The match start was delayed for 20 minutes by crowd violence at the Olympic Stadium which saw five supporters arrested and several injured.
Panathinaikos took the lead through Dimitris Papadopoulos on 25 minutes, who headed home Andreas Ivanschitz's right wing cross but AEK drew level within three minutes through a Gustavo Manduca penalty given against Ioannis Goumas for handball.
Dimitris Salpigidis missed forced a great save by AEK goalkeeper Stefano Sorrentino just before half time.
Europa League
Leicester City grab away win at AEK Athens as Vardy scores again
29/10/2020 AT 16:54
The winner came with a quarter of an hour remaining when Traianos fired home from the corner of the penalty box.
"It was lucky for AEK," said Panathinaikos midfielder Mikael Nilsson. "I don't think they made more chances than us. I don't think they played better than us. But they scored twice and we didn't."
Defeat leaves Panathinaikos in second place on 13 points, five behind the leaders. AEK are one point further back on 12 points alongside Egaleo, Larissa and Kerkyra.
Champions League
Horror scenes in Athens as AEK fan throws petrol bomb into visiting fans
27/11/2018 AT 19:14
Champions League
Bayern Munich cruise to win in Athens to go top of Group E
23/10/2018 AT 15:27