SALT LAKE CITY — They hugged at midcourt, Harvard’s Tommy Amaker and Siyani Chambers. The coach who had been underappreciated at Seton Hall and run out of Michigan embraced the freshman point guard who had been overlooked by the Big Ten. Together, they have worked wonders for the Crimson.

And their latest and greatest wonder was a stunning 68-62 upset of third-seeded New Mexico, the first NCAA Tournament win in Harvard’s history. Chambers has done things this season Jeremy Lin only dreamed of, and his masterful performance guided 14th-seeded Harvard (20-9) into tomorrow’s West Region third-round game against sixth-seeded Arizona (6:10 pm, TNT).

“I’m exceptionally proud of our guys,’’ Amaker said. “They had to believe. And we talked about preparation, we talked about passion, and we talked about belief. We battled a really good basketball team in a tough environment. I’m very proud of our guys.’’

Down 53-52 with 6:30 remaining after leading most of the way, Chambers, who had a game-high seven assists, made an impressive no-look pass to Laurent Rivard in the corner for a go-ahead 3-pointer. After a New Mexico turnover, Wesley Saunders hit a jumper as the shot clock wound down for a 57-53 lead. Kenyatta Smith, plagued by foul trouble against the Lobos’ bigs, pushed it to 59-53 with four minutes left.

“We had to have toughness and believe,’’ said Saunders, who had a team-high 18 points. “This is the type of thing you dream about when you’re in your backyard playing around. For it to actually happen, especially with this group of guys, I wouldn’t trade it.’’

Harvard held on from there, etching the name in the line of Ivy League feel-good stories that show academics and sports aren’t mutually exclusive, that the term student-athlete doesn’t always have to be a punchline.

Lin took to Twitter to get the last laugh. “YYYYYEEEEESSSSSSSSS!!! HARVARD winssss!!! hahahahhah i told you,” he posted.

The Crimson put four starters in double-figures, led by Saunders and Rivard (17). But the one who didn’t, Chambers, led them to the Ivy League’s first win in the tournament since Cornell made the regional semifinals in 2010.

“I think our defense was outstanding,’’ said Amaker, who took Seton Hall to the Sweet 16. “I thought our toughness and courage carried us through with what was in front of us.’’

Harvard’s story — and Chambers’ ascension — had twists and turns that would seem unlikely.

They suffered through academic controversies in August, when more than 100 students all turned in similar answers in an open-book, take-home final exam. The university started investigating, and not long afterward, Harvard’s co-captains — Kyle Casey and Brandyn Curry — withdrew from school.

Though many teams would have used that as an excuse, Chambers used it as an opportunity.

Amaker — who guided the Crimson to last year’s NCAA Tournament — hadn’t planned to give the freshmen that much playing time. But Chambers, a three-time state champion in Minnesota and that state’s Mr. Basketball, seized his chance.

He became the first freshman ever named first-team All-Ivy, and came into last night averaging 5.7 assists, tops in the league.

Led by Kendall Williams, Tony Snell and Alex Kirk (game-high 22 points), Mountain West Conference champion New Mexico (29-7) was one of the country’s best defensive clubs. Some viewed them as a darkhorse to reach the Final Four, and the university bestowed coach Steve Alford with a 10-year contract that pays him $2.5 million annually gave him a $125,000 bonus if he reached the final weekend.