Tua Tagovailoa threw a go-ahead 5-yard touchdown pass to Myles Gaskin early in the fourth quarter and the Miami Dolphins hung on to beat the New York Jets 24-17 on Sunday for their third straight victory.

A week after an impressive win over Baltimore, the Dolphins (4-7) overcame some penalties — and the Jets had some sloppy plays of their own — to get their first three-game winning streak since winning five in a row in the middle of last season.

CLICK HERE FOR MORE SPORTS COVERAGE ON FOXNEWS.COM

With the game tied at 14, Tagovailoa was facing heavy pressure when he got a throw off to Gaskin, who held onto the ball to put the Dolphins ahead 21-14 with 10:15 left despite getting hit by both C.J. Mosley and Isaiah Dunn in the end zone. Mosley took a helmet-to-helmet hit from Dunn on the play and left to be checked for a head injury.

The drive was helped by a roughing the passer penalty on John Franklin-Myers on third down from the 6, when Tagovailoa’s pass to Gaskin fell incomplete.

A penalty hurt the Jets (2-8) again on Miami's next possession, when Tagovailoa was sacked on third down — but it was wiped out by a holding call on Jason Pinnock. The Dolphins milked the clock and took a 24-14 lead with 1:57 remaining on Jason Sanders' 24-yard field goal.

Matt Ammendola, who missed two field goals, made a 35-yarder in the closing seconds to cap the scoring.

Tagovailoa finished 23 of 33 for 273 yards and touchdown passes to Gaskin and Mack Hollins with one interception. Receiver Jaylen Waddle had a 1-yard TD run for Miami, which took the all-time series lead for the first time since 2000 by going up 56-55-1 in the head-to-head matchup.

The Jets, who rebounded defensively after allowing at least 45 points in three of their past four games, couldn't make key stops late. And they couldn't get anything going consistently on offense.

Joe Flacco made his first start in place of the injured Zach Wilson, who missed his fourth straight game. New York opted to go with the 36-year-old Flacco over Mike White, saying the veteran would give them a better chance against Miami's aggressive defense.

Flacco was 24 of 39 for 291 yards and touchdowns to Elijah Moore and Jamison Crowder. Moore finished with eight catches for a career-best 141 yards.

CLICK HERE TO GET THE FOX NEWS APP

WHAT’S THE TIME?

Ammendola lined up to attempt a 56-yarder on the Jets’ first possession after halftime, but New York was called for delay of game. Coach Robert Saleh opted to take the penalty, possibly trying to draw Miami offside. New York then punted.

Tagovailoa launched a deep pass down the left sideline to a wide-open and waiting Hollins. The Dolphins receiver turned upfield and raced into the end zone to give the Dolphins a 14-7 lead with 9:06 left in the third quarter.

Ammendola was wide left on a 40-yarder, but the Jets sent the Dolphins on a three-and-out — and got some help from Miami on an interference call on the punt.

On third-and-8, Flacco zipped a pass across the middle to Moore, who caught the ball ahead of a diving Byron Jones and took off for a 62-yard TD to tie it at 14 late in the third quarter.

QUICK START

The Dolphins marched down the field against the Jets' struggling defense, going 83 yards on 11 plays to take a 7-0 lead on Waddle's 1-yard run off a handoff from Gaskin in the wildcat.

Tagovailoa was picked off by Ashtyn Davis on Miami's next possession, Michael Carter had a 39-yard run on first down to give New York first-and-goal at the 1. Three plays later, the Jets went for it on fourth down — and Flacco found Crowder in the end zone to tie it for New York.

DOUBLE DOINKS

The Jets had a chance to take the lead just before halftime, but Ammendola hit the left upright on a 55-yarder.

That gave the Dolphins the ball at their 45 with just over a minute left. But after they got down to the Jets 14, Sanders clanked a 32-yarder off the top of the right upright as time expired to keep the game tied at 7.

INJURIES

Dolphins: LB Brennan Scarlett went out with a knee injury in the second quarter and didn't return. ... S Brandon Jones left with an elbow injury. ... CB Jamal Perry was carted from the sideline with an injured right knee.

Jets: Carter left early in the third quarter with an ankle injury and didn't return.

UP NEXT

Dolphins: Host Cam Newton and the Carolina Panthers next Sunday.

Jets: Travel to Houston to take on the Texans next Sunday.