TUSCALOOSA, Ala. -- Alex Len finished with 15 points and 13 rebounds and had a key block in the final seconds to help Maryland escape with a 58-57 victory over Alabama on Tuesday night in the NIT quarterfinals.

Len's fifth block came on Rodney Cooper's drive with 3 seconds left, but the ball went out of bounds. Then Trevor Lacey got off another potential game-winner at the buzzer after a pump-fake, but it bounced off the rim.

The Terrapins (25-12) are making their first trip to the NIT semifinals at Madison Square Garden since 2005 and are seeking their first title since 1972.

"We've been talking about trying to get a great road win, and to get a postseason win against a team that I thought should have been in the NCAA tournament was just a great win," Maryland coach Mark Turgeon said. "Our defense was just spectacular all night.

"We just held on. I don't like just holding on, but this time of year any win is a great win."

Alabama (23-13) wiped out most of a 10-point second-half deficit but never reclaimed the lead.

Len had been on the bench with four fouls, but came up big at the end despite missing two free throws with 27 seconds left. Dez Wells and Jake Layman each had 13 points.

Levi Randolph led Alabama in scoring for the third straight NIT game with 15 points. Cooper had 13 and Trevor Releford 11. Lacey had eight assists but was 1 of 6 shooting for five points.

"Our guys never stopped fighting, never quit, I thought gave great effort and gave us a chance at the end," Tide coach Anthony Grant said.

The Terrapins had controlled the second half in their first two NIT games, but this time managed to hold off several Alabama rallies.

"We're excited to go to Madison Square Garden," Len said. "It was just a huge win for our program."

Alabama cut a 10-point second-half deficit down to 48-47 when Cooper got a layup off a nice pass from Lacey.

The Terrapins answered with a 3-pointer by Pe'Shon Howard -- his first points of the game -- and two more by Layman, who celebrated the second with a little dance and a yell as he came back up the court with Maryland's lead back to 57-49 and 3:40 remaining.

Cooper and Nick Jacobs both converted three-point plays and Wells was called for traveling on two straight possessions after Len made 1 of 2 from the foul line.

Releford drove to the basket with 47 seconds left, cutting it to 58-57.

Nick Faust nearly lost the ball against the full-court press but managed to drive to the basket. He missed the shot but Len grabbed the rebound and drew the foul.

He missed both free throws with 27 seconds left and Randolph rebounded the second and crossed midcourt before Alabama called timeout.

Randolph inbounded to Lacey, who managed to get off the final attempt.

"I feel like Trevor got a good look," Randolph said. "We drew up an inbounds play and he came up. He got a good shot up."