MIAMI GARDENS, Fla. — Miami defensive end Derrick Shelby batted the pass in the air, caught it and sprinted to the end zone with quarterback Matt Schaub chasing him in vain.

Once Shelby and the Dolphins built a 15-point lead, the Baltimore Ravens couldn’t quite catch them, either.

Miami intercepted a pair of deflected Schaub passes to score two touchdowns 20 seconds apart late in the first half, and held on to win 15-13 Sunday. The Ravens had the ball in Miami territory twice in the final six minutes, but the Dolphins turned them away.

“We had to grind it out today,” Shelby said.

Miami (5-7) managed only eight first downs but improved to 4-4 under interim coach Dan Campbell, and ended a streak of five consecutive losses to the Ravens (4-8).

The score was 0-0 when Reshad Jones intercepted a pass batted by defensive tackle Jordan Phillips to set up the game’s first score. On the next play, Ryan Tannehill hit a leaping DeVante Parker at the goal line for a 38-yard touchdown.

Three snaps later, the 280-pound Shelby batted a pass in the air, caught it and ran 22 yards to the end zone for his first NFL touchdown.

“I got free. I got my hands up. I got the tip,” Shelby said. “Touchdown.”

advertisement | advertise on newsday

The pick-six was the second in as many games for Schaub since he replaced Joe Flacco, who is out for the season with a knee injury.

“It’s part of the game, it happens, and that was the difference in the game,” Schaub said.

After Miami’s second touchdown, the Ravens committed consecutive penalties on the ensuing extra point to put the ball at the 1, and Jay Ajayi ran for a 2-point conversion. That became the margin of victory.

The Ravens’ eight losses have been by a total of 34 points.

Miami mounted a goal-line stand in the second quarter, and repeatedly stopped the Ravens down the stretch. Olivier Vernon totaled 2 1/2 sacks, one on third down with the Ravens nearing field goal range and five minutes left.

NFL videos

Baltimore recovered a fumble to get the ball back but failed to pick up a first down, and Justin Tucker was wide right on a 55-yard field goal try. Tucker is the second-most accurate kicker in NFL history.

The Ravens again took over at their 20 with 20 seconds left and were unable to reach midfield.

“It felt good to make big stops in critical situations,” cornerback Brent Grimes said.

Injury-plagued Baltimore lost despite outgaining Miami 375-219 and controlling the ball for nearly 38 minutes. Schaub threw for 308 yards — and the two interceptions.

“Those are the two plays in the game that made the difference,” Ravens coach John Harbaugh said.

advertisement | advertise on newsday

Schaub appeared to be shaken up several times but didn’t miss a snap.

“I was fine,” he said. “I just need to put everything back in place.”

The Dolphins’ two scores off turnovers were the extent of their point production, and new play-caller Zac Taylor couldn’t get the offense going.

Miami ran more than in recent games, and Lamar Miller rushed for 113 yards. But Tannehill went 9 for 19 for just 86 yards.

“We’ve got to be more productive,” Campbell said. “But we did what we had to do to win the game. Our defense played lights out.”

advertisement | advertise on newsday

The biggest lapse came when Javorius Allen turned a screen pass from Schaub into a 41-yard play for the Ravens’ touchdown. Baltimore drove 60 yards in the final minute of the first half to kick a field goal, and added another field goal early in the fourth quarter.

A disputed penalty against the Ravens cost them a touchdown in the first quarter. Schaub threw long to Daniel Brown for a 52-yard score, but it was negated by an offensive pass interference penalty on Brown, who had only minimal contact with the defender.

Harbaugh contended the defender was guilty of interference, and said a first-year official made the call.

“I think he got it backward,” Harbaugh said. “He’s a rookie, and he messed it up.”

NOTES: Ravens TE Crockett Gilmore left In the second quarter with a back injury. ... Miami reserve DT Robert Thomas left in the fourth quarter with an elbow injury. ... Harbaugh’s brother, Michigan coach Jim Harbaugh, watched the game from the Ravens’ sideline and was in the locker room afterward.