Ferrari driver Sebastian Vettel held off a tremendous late charge from Mercedes rival Lewis Hamilton to win the Bahrain Grand Prix and take the overall lead in the Formula One title race.
Hamilton was catching the German on every lap, but ultimately ran out of time and finished almost seven seconds behind.
"The car was really amazing to drive," Vettel said. "Lewis was a threat towards the end and with the traffic, you never know."
Vettel and Hamilton were level with a win each heading into this race, but Vettel's second victory of the season and 44th of his career puts him in command.
Mercedes driver Valtteri Bottas finished third - his 11th podium - after starting from pole position for the first time in his career, while Ferrari's Kimi Raikkonen was fourth.
Bottas made a clean start, but Hamilton was beaten for pace by Vettel, who overtook him heading into the first corner.
Hamilton's hopes were also hit, when the British driver was given a five-second time penalty early into the race for driving too slowly in the pit-lane and holding up Red Bull's Daniel Ricciardo, who was fifth.
"The pit lane was really my fault, so apologies to my team for losing time there," Hamilton said. "Ferrari did a great job today."
There is strong mutual respect between three-time F1 champion Hamilton and four-time champion Vettel, and Hamilton gave him a warm handshake after the race.
Vettel completed the 57 laps of the 5.4-kilometre (3.4-mile) track in 1 hour 33 minutes 53 seconds, for his third win in Bahrain, after success with Red Bull in 2012 and 2013.
It was 24 degrees Celsius (75 Fahrenheit), with a refreshing breeze, when the race started at 6pm local time and it finished under floodlights.
"The last half of the [final] lap, with the fireworks ... I love what I do," an emotional Vettel said on the podium.
Bottas got away cleanly, but crucially, Hamilton was beaten for pace by Vettel, while Max Verstappen rocketed up from sixth to fourth, after passing Raikkonen and Ricciardo.
With Bottas losing power in his rear tires, Vettel sensed it was the right time to pit for new tyres on lap 11. Verstappen asked his team to match that strategy and he came in on the next lap.
But moments later, the Dutchman's brakes failed, and he drifted across the track and into the wall, his race over. The 19-year-old Verstappen, who had driven so well from 16th place on the grid to finish third in China last weekend, climbed out and kicked the barriers in frustration.
The incidents were coming fast, with 18-year-old Lance Stroll hit from the side on lap 13 by Carlos Sainz Jr, forcing the safety car to come out. Both Mercedes drivers used the safety car incident to pit for new tyres, but Hamilton made the mistake of holding up Ricciardo.
When the race began in earnest again on lap 17, Hamilton burst straight past Ricciardo into third, while Vettel brilliantly defended the corner twice to fend off Bottas.
By the halfway point, Vettel's lead was six seconds over Hamilton, who had just passed Bottas, who pitted soon after.
There was some frantic action behind the leaders, with Fernando Alonso battling it out in midfield. He was not happy with his car's performance, though, saying "I've never raced with less power in my life" over the radio.
With Hamilton gaining fast, Vettel came in for his second tire change on lap 34 and came out in fourth place behind Raikkonen.
Hamilton was the new race leader, but with more than 20 laps to go, a time penalty still to take and with Vettel on new tyres, it was a precarious lead. Hamilton's strategy was to make his tires last as long as possible, but he came in with 15 laps left and took his time penalty.
This put Bottas in second place, but he then backed off to let the quicker Hamilton through to chase Vettel down.
"Thanks to Valtteri for being a gentleman," Hamilton said.
Meanwhile, Alonso retired one lap from the end, making it a third straight race without a point for McLaren.
Team-mate Stoffel Vandoorne did not even start, because of an engine failure.