HARRISONBURG, Va. — The Maryland women’s basketball team needed nearly 36 minutes to warm up on a frigid November night in their first road game of the season. But once they got hot, the Terrapins burned through James Madison’s 19-point lead in the fourth quarter to narrowly escape an upset on the road.

No. 8 Maryland clawed its way back with a 14-2 run in the final four minutes of Wednesday’s game to beat the Dukes, 70-68, a sigh of relief breathed only when Kamiah Smalls’s half-court heave as time ran out clanked off the rim at James Madison’s Convocation Center.

Smalls, a senior guard who helped lead a smooth-operating Dukes team with 14 points but turned the ball over twice in the final three minutes, fell to her knees and pounded the court with her fists when the final buzzer sounded. James Madison was a fortuitous bounce away from a massive upset after controlling the game nearly until the end.

Things changed late in the fourth quarter when the Terps began running their offense through 6-foot-5 sophomore center Shakira Austin. The Dukes shot better than Maryland for three quarters, hung with them on the boards — losing that battle just 44-38 — and had two fewer turnovers. But the Terps survived behind a late-game press and a half-court defense that found its footing only in the final quarter.

“I’m crushed,” Dukes Coach Sean O’Regan said. “I put it all on me — if we had figured out something mentality wise, press-break wise, defensively in the fourth quarter. . . . The bottom line is we didn’t finish.”

Austin led Maryland with 20 points, 17 of which came after halftime. Freshman point guard Ashley Owusu had 14 points — including the decisive layup, curling around the right side of the key with three seconds to go — and sophomore guard Taylor Mikesell had 10 in another off-shooting night for the Terps, who also struggled in Sunday’s loss at home to South Carolina.

A deep three-pointer from Nikki Oppenheimer to start the fourth quarter pushed James Madison’s lead to 60-41. The Terps, running out of cards to play at that point, turned to their press — and it quickly paid dividends, chipping away at the margin until a driving layup from Austin got Maryland within single digits with 3:37 to play.

Only then did James Madison’s previously unshakable calm show some cracks; the Dukes had three turnovers in the final three minutes, which the Terps converted into points.

“Uncharacteristic, out of rhythm, first time on the road and obviously still trying to find our chemistry,” Maryland Coach Brenda Frese said. “Proud of the fourth quarter. We could’ve put our heads down. We brought a lot more energy on the defensive end. I thought Shakira was huge for us in that fourth quarter when you talk about the presence that she made and the team in general, the plays that we had to make on the defensive end to get that back.”

Senior Kaila Charles attributed the Terps’ slow start to too much one-on-one play and a lack of communication on defense. Maryland was in a 16-point hole midway through the second quarter.

“We weren’t really bought into our system in the beginning,” Charles said.

As in their game against South Carolina, porous defense translated into poor shot selection as the Terps couldn’t find rhythm in the up-and-down, transition offense in which they usually thrive. They shot 34.5 percent from the field before halftime.

The experienced Dukes made scoring against Maryland look easy, whizzing by low-post defenders for layups and hitting jumpers and one-handed bank shots from wherever they pleased. The Terps took care of the basics — they rebounded well and kept their turnovers relatively in check — but were unable to establish control.

Even when Maryland dented the Dukes’ lead, as the Terps did with a 12-3 run in the second quarter that looked promising for a spell, James Madison kept its nerve.

In the fourth, the Terps finally used their best mismatch — Austin — to shift momentum.

“We just came out a lot more aggressive. It started off with steals, being able to turn defense into offense, just slowly just knowing that you’ve got to attack,” Austin said. “. . . Go into their body, stuff we’d been talking about all game. We were able to apply it in the fourth quarter, finally.”

Note: Maryland signed the No. 2 player in the class of 2020 to a national letter-of-intent Tuesday, keeping Frese’s stellar recruiting streak alive.

Baltimore native Angel Reese is Maryland’s highest-ranked commit in program history. The 6-3 swing player out of Saint Frances Academy is the top-ranked wing in her class and helped lead her AAU squad, Team Takeover, to the 2019 EYBL national title.

She averaged 18 points, 20 rebounds and five assists in her junior year.