Baltimore finished with six sacks, three by Terrell Suggs.
"We weren't perfect, but we made plays we needed to," Suggs said.
Justin Tucker kicked a 44-yard field goal to put the Ravens ahead with 1:42 left.
Then Tannehill, under pressure all day, scrambled to his left before completing a 46-yard pass to Brandon Gibson on fourth down to keep the Dolphins' hopes alive and give them a first down at the 34.
Dumervil pushed them back to the 39.
"We had good coverage, and I was able to make the play," he said.
That might have been enough to make Sturgis miss. He was wide left with 33 seconds to go.
"Bad time to miss," said the rookie, who had been 10-for-10. "I wanted to make sure I got it there. Unfortunately, I hooked it pretty good."
The Ravens (3-2) rediscovered their ground game, bounced back from a loss last week at Buffalo and won on the road for the first time this season.
The Dolphins (3-2) lost their second game in a row, with their pass protection again a culprit. Tannehill came into the game with 18 sacks, the most of any NFL quarterback.