The 29-year-old, who joined Southampton from Hull in 2014, was instrumental for the side last season, scoring 13 goals in all competitions and helping them qualify for the Europa League.
"I'm delighted. I'm excited to be part of what could be a big future in the next four years for this," the Ireland international told the club's website.
"I love it here, the set-up, the training ground, the lads as well - everyone around the club. It's a real family feel, and I feel like I'm a big part of that and I feel like I'm playing my best football here as well."
Long played all four games of Ireland's Euro 2016 campaign, where they lost to finalists France in the last 16.
Southampton continue to tie up key players on long-term deals after handing new contracts to Ryan Bertrand, Virgil van Dijk, Fraser Forster, James Ward-Prowse and Steven Davis in recent months.
Executive Director of Football Les Reed said: “Shane has been an important asset to the team ever since his arrival at the club in 2014, and he was an influential part of our record-breaking Premier League campaign last season.
We use your sign-up to provide content in ways you've consented to and to improve our understanding of you. This may include adverts from us and 3rd parties based on our understanding. You can unsubscribe at any time. Read our Privacy Policy
“His experience and character also make him an extremely valuable member of the squad off the pitch, as well as on it, and I am delighted we have strengthened our commitment with him.
“Shane is the latest in a significant number of first-team players to have signed new contracts with the club in recent weeks and months, indicating the players' belief that there is more to come, while further strengthening the core of our squad as we move into what promises to be another memorable campaign.
“Shane is one of many exciting attacking options that we have at our disposal, and he will no doubt play an important part in the season and the years ahead.”