The 26-year-old joined the Brazilian heavyweights on loan last summer. He has registered five goals and an assist from 24 appearances.
Earlier last week, the club’s hierarchy opened talks with United over a permanent move, and an agreement has now been struck.
The Serie A outfit will pay €10.5 million (£8.9m) for the midfielder’s permanent signature. The deal will include a 25% sell-on clause.
Flamengo will settle the fee in instalments until 2024. With the transfer window open, Pereira will sign a long-term deal until December 2026
Pereira has revived his career with Flamengo. He was an integral part of the starting line-up during the back end of last season.
The campaign ended on a sour note with his late blunder costing Flamengo the Copa Libertadores title against Palmeiras in November.
The incident has not had any impact on his future. Flamengo have decided to show their confidence in him with a permanent transfer.
The move works well for both clubs. Pereira will commit to the club for the long-term, and could boost his international prospects with Brazil.
Meanwhile, the Red Devils will receive a guaranteed £8.9m for a player, who previously had a disappointing loan stint at Lazio.
Hopefully, the funds will go into strengthening the squad. A new defensive midfielder should be a top priority ahead of next season.