Penn is going dancing after a classic Ivy League championship game, fittingly played between the two best teams.

In a game where both teams traded 13-point leads, Penn edged Harvard, 68-65, in a charged-up Palestra on Sunday to earn the automatic NCAA berth.

The Quakers (24-8), who will face Kansas in Wichita on Thursday, will be making their first NCAA appearance since 2007. Harvard finished its season 18-12. The teams tied for the regular-season Ivy League title.

[Click here to print out your 2018 NCAA tournament bracket]

"(It was) two heavyweights playing and their kids playing great and our kids playing great and I thought it was a true testament of what the league is like," Penn coach Steve Donahue said. "I am obviously extremely proud of our guys, but I thought the league was represented great tonight."

Darnell Foreman led Penn with 19 points, all scored during a first half with some serious swings in which Harvard went on a 16-0 run and the Quakers scored the final 13 points of the half. The run would reach 28-2 when the Quakers scored the first 11 points of the second half.

AJ Brodeur, who scored 16 points and grabbed 10 rebounds, was named the most outstanding player of the tournament.

Penn's turnaround was completed in only three seasons. Donahue inherited a team that was 9-19. In his first two seasons, the Quakers had losing records, but were building with young players. This year, the Quakers tied Harvard for the Ivy League title and now Penn is heading to the NCAAs.

"We realized we have done it," Foreman said. "Like the Sixers, we have completed the process."

Trailing 60-57, Penn scored nine unanswered points on two Caleb Wood three-pointers and a three-point play by Ryan Betley for a 66-60 lead with 2 minutes, 4 seconds left.

Betley, the sophomore from Downingtown West who finished with 17 points, got more than he bargained for on the drive.

"The shot clock was winding down and I was trying to draw the foul," he said.

Wood made only 1 of 7 shots in the first half, but Penn kept calling his number. Both three-pointers were off plays designed specifically for Wood, who ended with 12 points.

"It felt amazing" Wood said about the two threes. "I had kind of a rough first half but my coaches and teammates still believed in me the whole time, still called my number."

[March Madness 2018: TV schedule, game times and announcers]

Harvard's Christian Juzang hit a three from the top of the key with 48 seconds left. Betley missed on a forced drive to the basket. Harvard's Justin Bassey made two free throws, cutting the lead to 66-65 with 14.6 seconds left.

Betley was fouled with 12.4 seconds remaining and made both foul shots, extending the lead to 68-65. Bassey then missed a long three, Harvard got the rebound and kicked it out to Juzang, whose shot wasn't close from three-point range.

"We rushed (the first shot) a little bit without a doubt, but sometimes that happens in a frenzied situation," said Harvard coach Tommy Amaker, who lost Ivy League player of the year Seth Towns for the final 8:20 of the game because of an injury. "We did a good job of getting more than one shot at it and that is what you want."

Towns made a layup to increase Harvard's lead to 30-17 with 4:58 left in the first half.

Penn's offense came alive, outscoring the Crimson 17-2 to end with a 34-32 halftime lead.

Foreman personally kept the Quakers in the game with his 19 first-half points, hitting all three of his three-point attempts, including one with 1 second remaining that gave the Quakers their halftime lead.

Penn started the second half the way it ended the first. The Quakers scored the first 11 points of the second half, giving them a 45-32 lead.

All told, Penn scored 24 unanswered points before Towns ended what had been a 28-2 run on a three-pointer with 16:05 left, making it 45-35.

The Crimson kept charging back, but Penn had enough to hold them off.