The Walt Disney empire is to buy the superheroes stable Marvel Entertainment for $4bn (£2.5bn) in a star-studded Hollywood deal that unites family names such as Mickey Mouse with lucrative characters including Spider-Man, the Incredible Hulk and the X-Men.

Disney hopes to put Marvel's 5,000 characters to work on its television channels and in video games, theme parks and movies. The agreed takeover is for a mixture of cash and stock, with Disney shares accounting for roughly 40% of the buyout price.

The tie-up unites two companies with similar business models – they both take characters which capture the popular imagination and promote them vigorously around the world on every possible media platform and through third-party licensing deals.

While Disney has traditionally been known for its wholesome family creations ranging from the Little Mermaid to Lion King, Hannah Montana and Pocahontas, the purchase of Marvel adds an edgier, more violent element – it recently scored a box office success with Iron Man, a movie starring Robert Downey Jr as a billionaire inventor who creates a hi-tech suit of armour to battle evil.

Marvel's characters, who include superhero Captain America, tend to chime particularly well with teenage boys and young men, while Disney has been stronger in appealing to a female audience.

"There are so many opportunities to mine both characters that are known and characters that are not widely known," Iger said.

The tie-up is one of the largest US corporate transactions of the summer and marks a remarkable turnaround for Marvel, originally a comic book company, which filed for bankruptcy in 1996 under heavy debts as it faced a slump in comic book sales.

The two companies hope to complete the deal by the end of the year. Marvel's chief executive, Ike Perlmutter, will be the largest personal winner, scooping $1.4bn in cash and Disney shares in return for his 37% stake in the business.

Perlmutter has been involved in running Marvel since helping to buy the business out of bankruptcy in 1998.

Marvel's chairman, Mort Handel, described Disney as a "perfect home" for his company's library of characters. "Both companies have their roots in great storytelling and innovative artistry," he said.

Marvel had sales of $676m last year but employed just 300 people. Disney, in contrast, had a turnover of $37.8bn and a payroll of 150,000 staff at businesses varying from its Hollywood film studios to ABC television, theme parks on three continents and a high-street chain of Disney merchandise stores.

"This helps give Disney more important exposure to the young male demographic that they have sort of lost some ground with in recent years," said David Joyce, a media analyst at stockbroker Miller Tabak.

He added: "When you look at the kind of TV shows on their cable networks, and the Disney consumer products line for the princess and fairies – the Hannah Montana kind of stuff – it shows that they have a lot of strength addressing the young female demographic."

In a research note, Citigroup analyst Jason Bazinet said: "Disney will also be able to monetise Marvel's brands across its entire ecosystem from TV to parks, movies, consumer products and video games."

Marvel's shares shot up by 26% to $48.78 during early trading on Wall Street. The buyout values Marvel at $50 per share.