Real had earlier looked set to win the trophy in their first competitive game since the departures of Cristiano Ronaldo and coach Zinedine Zidane when a Sergio Ramos penalty put them 2-1 up in the second half.
That came after Karim Benzema cancelled out Diego Costa's first-minute opener in the Estonian capital, but Costa hauled Diego Simeone's side level again late on to force extra time.
Simeone's men then looked stronger in the extra period as they won this competition, the annual meeting of the Champions League and Europa League winners, for the third time in nine seasons.
"I stayed at Atletico because the project is a good one. I have confidence in this club, in the coach and I saw tonight that I was not mistaken," said Atletico striker Antoine Griezmann who was linked with a move to Barcelona in the summer.
Atletico defender Lucas Hernandez added: "To win this trophy is something great but to do it against our eternal rival is even better."
Real had won the trophy under Zidane in each of the last two years, and emerged victorious against their neighbours in the Champions League finals of 2014 and 2016.
But this result comes after a close season in which Atletico have strengthened while Real look to have gone backwards, with no replacement signed for Ronaldo after his move to Juventus.
Griezmann started for Atletico at the compact Lillekula Stadium, fresh from helping France to World Cup glory last month.
In contrast, former Spain coach Lopetegui left Luka Modric on the Real bench at kick-off, seeking to ease the Croatian playmaker back after he led his country to the World Cup final.
Goalkeeper Thibaut Courtois did not feature at all following his recent arrival from Chelsea, while nine of Real's starting line-up also started May's Champions League final win over Liverpool in Kiev.
Atletico also had France winger Thomas Lemar making his competitive debut following his €72 million move from Monaco, and they took the lead after just 49 seconds.
With Simeone watching from the stands as he serves a touchline ban, Costa met Diego Godin's long ball forward with his back to goal and nodded it over Ramos before turning to burst through and rifle a shot home from a tight angle.
It was a superb finish, but Real were level just before the half-hour via a combination of the two men expected to step up following Ronaldo's departure.
Gareth Bale delivered a cross from the right and Benzema headed past Jan Oblak at the far post.
Lopetegui sent on Modric for Marco Asensio just before the hour mark and Real took the lead shortly after, Ramos scoring a 63rd-minute penalty awarded for a Juanfran handball.
It looked like that would win it, yet Atletico showed great resolve to level the scores again in the 79th minute as Juanfran and substitute Angel Correa combined to set up Costa to stab home.
Into extra time they went, and Atletico went ahead again in the 98th minute, Thomas Partey pressing to win back possession before holding up a cross for Saul to thump a superb left-foot volley past Keylor Navas from 17 yards.
The powerful Costa and substitute Vitolo then set up Koke to make it 4-2, securing victory and giving Atletico their seventh trophy since Simeone took charge in late 2011.
Now they will hope to push Barcelona and Real all the way in La Liga, with their opening game at Valencia on Monday, after Lopetegui's side host Getafe on Sunday.
COMMENTS
Comments are moderated and generally will be posted if they are on-topic and not abusive.
For more information, please see our Comments FAQ