Allen's lay-in with 2 minutes left gave the Terrapins an eight-point advantage at 80-72, but Seth Curry drained successive 3-pointers down the stretch to make it close.
Duke's Rasheed Sulaimon made three foul shots with 17 seconds left to tie the score, but Allen (16 points) drove to the basket and was fouled by Quinn Cook, setting up the decisive foul shots.
Alex Len had 19 points and eight rebounds for Maryland (18-7, 6-6 ACC), which downed Duke in what may have been the rivals' last-ever meeting at Comcast Center -- the Terps are joining the Big Ten starting in 2014.
Curry finished with 25 points while Cook added 18 and Sulaimon netted 16 for the Blue Devils (22-3, 9-3 ACC), whose six-game winning streak was snapped.
Swim Week Miami Beach 2014 [PHOTOS]