Nathan Broadhead headed Everton into a 72nd-minute lead from Luke Garbutt's cross.
But Pompey hit back almost immediately when Theo Widdrington converted a penalty after Nathan Markelo had fouled Dan Smith.
Lavery won the tie after another Garbutt cross was headed into his path by fellow substitute Antony Evans.
In their next PL Cup fixture, Portsmouth visit Leicester City on Monday 13 November.
Everton will be back in Premier League 2 action on Friday 13 October, when they play Manchester City at the City Football Academy.
(Photo courtesy of Portsmouth FC)