Microsoft Corp. MSFT +1.19% is hoping a cult videogame built around virtual blocks will help fix the company's real-world problems, even if the brains behind the brand aren't sticking around.

The software giant's $2.5-billion deal to buy Mojang AB, maker of the "Minecraft" videogame, gives Microsoft an entertainment property whose devoted fans dress up like game characters, pack YouTube with how-to guides and rush to sign up for "Minecraft"-themed summer camps.

Microsoft, which had tried before to buy Mojang, moved quickly to secure a deal as other potential suitors expressed interest, said a person familiar the matter. The two companies signed an exclusivity agreement in July, this person said, when it became clear that Mojang's founders were open to selling.

Microsoft is betting the popularity of "Minecraft," which lets people use Lego-like blocks to create lush digital worlds, can lure more people to the company's struggling Windows smartphone system, and draw into its orbit a younger crop of users and software developers.

"Great content will drive the ability for Microsoft to expand the sales of its platforms, and bring it to new devices," said Kent Wakeford, chief operating officer of Kabam Inc., which makes videogames such as "Kingdoms of Camelot."

The acquisition isn't a big financial bet for a company as flush with cash as Microsoft, but Chief Executive Satya Nadella is taking a risk that "Minecraft" can have staying power and will prove bigger than a single brand.