Barkley gathered an offensive rebound off Prince Williams' miss with five seconds left before burying the game winner. Williams - who finished with 18 points - scored seven straight points for the Pirates before the miss.
Temple's Josh Brown made two free throws with 21 seconds left to tie it at 61.
Obi Enechionyia hit a 3 with 9:31 left to play to give Temple at 52-47 lead, the largest lead either team held in the contest. Enechionyia led the Owls with 18 points.
East Carolina (10-11, 2-6 American Athletic) got 14 points from B.J. Tyson. Williams and Tyson made 12 of Temple's 25 field goals.
Quenton DeCosey had 14 points and 11 boards for Temple (11-8, 5-3).