GREENVILLE, N.C. (AP) -- Patrick Pinkney threw for 406 yards and three touchdowns in his first start and Ben Hartman shook off three missed field goals to kick the winner on the final play in East Carolina's 34-31 win over North Carolina on Saturday night.

Chris Johnson added two touchdown catches and a rushing score for the Pirates (1-1), who held on for a thrilling victory in their home opener against their instate rival. It was only East Carolina's second victory in 11 tries -- the last coming 32 years ago -- against the Tar Heels (1-1).

Pinkney, a former third-stringer, completed 31 of 41 passes and finished with the second-best passing game in school history. Hartman missed field goal attempts of 30, 32 and 37 yards before nailing the 39-yarder on the final play, sending the purple-clad Pirates spilling onto the field in a celebration that turned into a playful mob at midfield.

Brandon Tate scored three touchdowns for North Carolina, which suffered its first loss under new coach Butch Davis. Redshirt freshman T.J. Yates threw for 344 yards and three touchdowns for the Tar Heels, who had plenty of chances themselves to pull this one out. That included a bobbled snap by Ryan Baucom on a 52-yard field goal attempt for the lead in the final minute, setting up East Carolina's final drive.

The teams went back and forth almost the entire way. Tate's 58-yard punt return for a score on the final play of the third quarter sent the game into the final period tied at 31.

Pinkney seemed to gain confidence with every throw. After the Tar Heels' botched field goal attempt, the junior connected on two clutch passes to put the ball at North Carolina's 21-yard line. Then, after Pinkney took a knee in the center of the field and called timeout with 2 seconds left, Hartman made the kick.

It was a worthy way to follow up a gutsy effort in a 17-7 loss at Virginia Tech last week in which Pinkney came off the bench and turned in a steady performance that earned him the starting job against the Tar Heels.

Pinkney's mobility allowed him to find time against oncoming rushers, and he got some early confidence with a 78-yard screen pass to Johnson for a score on the Pirates' first possession. Then, after finding Davon Drew for a 15-yard touchdown late in the first half, he connected with Johnson for a 24-yard score in the third quarter.

Johnson finished with five catches for 136 yards, and had a 4-yard TD run late in the third quarter for a 31-23 lead.