The deal comes after Sony’s Amazing Spider-Man 2 under-performed at the box office last year.
Despite a respectable $709m (£465m) box office haul, it was the lowest-grossing of Sony’s five Spider-Man films so far.
The character could now appear in Marvel films such as Iron Man and Thor.
However, the timing of the deal makes it likely his first outing will be in 2016’s Captain America: Civil War. The character already appears in the comic book version of the story.
Marvel will then co-produce the next solo Spider-Man outing, financed by Sony Pictures, which will be released in 2017.
Kevin Feige, the Marvel boss who has overseen 10 consecutive box office blockbusters, including Avengers Assemble and Guardians of the Galaxy, will be involved in all future creative decisions about Spider-Man.
He will work alongside Amy Pascal, the Sony executive who recently stood down following a cyber-attack that saw her private emails leaked.
Fans have been clamouring for Spider-Man to join Marvel’s roster on the big screen for more than a decade.
The character is part of the Marvel’s comic book empire, but Sony has owned the film rights since 1999, when it paid a reported $7m (£4.6m).
Evil Dead director Sam Raimi first brought the character to the big screen, with Tobey Maguire in the lead role.
More recently, the series was rebooted, with British actor Andrew Garfield inside the iconic red and blue suit and Marc Webb directing.
But the new deal effectively spells the end for Garfield’s portrayal of Peter Parker and his superhero alter-ego, reported the LA Times.
Sony had been casting around for ways to re-invigorate the franchise after his second outing failed to break the $1 billion (£657 million) mark at the box office last May.
A third Amazing Spider-Man film was postponed to 2018, while a spin-off film, The Sinister Six, focusing on Spider-Man’s most notorious enemies, was slated for 2016.
There was also discussion of introducing a female set of heroes in their own films; and a potential film based around Peter Parker’s Aunt May.
But, at the same time, Sony was holding discussions with Marvel – as revealed in emails leaked as a result of last year’s cyber-attack.
Those emails showed that Marvel was pushing for Spider-Man to appear in the next Captain America movie; while Sony Pictures president Doug Belgrad wanted a Marvel-produced Spider-Man movie in which Sony retained “creative control, marketing and distribution.”
Although those talks were said to have stalled in December, the new announcement effectively fulfils all of those criteria.
It has also led to Marvel reshuffling the release dates of its upcoming movies.
The next Thor movie would have gone head-to-head with a new Spider-Man movie in the summer of 2017. It will now move to November of that year, shunting a film based on the Black Panther character into the following year.
The two-part Avengers: Infinity War movies, however, will not budge.
“The deal comes at a time when Sony needs not only hits at the box office but major franchises,” wrote Marc Graser in Variety magazine.
“It’s why Ghostbusters is being revived, this time with a female cast, and why properties like Uncharted, based on Sony’s hit videogame franchise are finally getting a greenlight.”
“This is the right decision for the franchise, for our business, for Marvel, and for the fans,” said Sony chairman Michael Lynton.
“I am thrilled to team with my friends at Sony Pictures along with Amy Pascal to produce the next Spider-Man movie,” said Marvel Studios President Kevin Feige in a statement.
“Amy has been deeply involved in the realisation on film of one of the world’s most beloved characters. Marvel’s involvement will hopefully deliver the creative continuity and authenticity that fans demand from the MCU [Marvel Cinematic Universe].
“I am equally excited for the opportunity to have Spider-Man appear in the MCU, something which both we at Marvel, and fans alike, have been looking forward to for years.”