Nick Folk kicked a 48-yard field goal with two seconds remaining after Lavonte David’s personal foul on Smith following a big run gave him the chance as the Jets pulled out an improbable 18-17 victory over the Tampa Bay Buccaneers in the season opener Sunday.

‘‘I just went out there,’’ Smith said, ‘‘and told those guys it’s never over.’’

Get Sports Headlines in your inbox:

The Globe's most recent sports headlines delivered to your inbox every morning.

Trailing, 17-15, Smith scrambled for 10 yards and was shoved while he was out of bounds by David. The 15-yard penalty put the ball at the Buccaneers’ 30 and Folk won it.

‘‘Man, oh man,’’ Jets coach Rex Ryan said. ‘‘We talk about a resilient group, and we certainly have it. We fought all the way to the end.”

The Jets jumped up and down on the field and on the sideline in exuberant celebration moments after things appeared dim for them. Rian Lindell had kicked a 37-yard field goal with 34 seconds left to put the Bucs on top, 17-15.

‘‘If there’s time on the clock, I expect us to go out there and execute,’’ Smith said. ‘‘And that’s what we did today.’’

From the Jets’ 20, Smith found Kellen Winslow deep down the middle for a 25-yard gain. Then, with the seconds ticking away, the Bucs got pressure on Smith, who rolled right and took off down the sideline. He ran out of bounds — and David inexplicably shoved Smith.

‘‘I don’t know what to say,’’ David said. ‘‘They called a flag. I guess I hit him out of bounds. Everybody told to me to keep my head up. All the guys in here were very supportive.’’

Smith, starting with Mark Sanchez out with a shoulder injury, had an interception and a fumble that led to a score, but was mostly solid. He went 24 of 38 for 256 yards with a touchdown to Winslow. Smith also led New York with 47 yards rushing.

The Jets also ruined the return of Darrelle Revis, their former star cornerback who had one tackle and two passes defensed.

Josh Freeman was 15 of 31 for 210 yards with a touchdown and an interception for Tampa Bay.