Fred becomes Jose Mourinho’s second signing of the summer following the arrival of defender Diogo Dalot from Porto.
Manchester United announced earlier this month they had agreed a deal with Shakhtar, which Sky Sports News understands to be in the region of £52m plus bonuses, but had been waiting for Fred to be granted a work permit.
He is currently in the Brazil squad at the World Cup, but did not feature in the 1-1 draw with Switzerland in their opening game.
Manchester United manager Jose Mourinho said: “Fred will complement our other midfielders’ qualities, which we need; his creative brain and passing vision will give us another dimension to our game.
“I am very happy he is joining our club and I believe our players know how important he can be in our team.”
Fred, who has an option to extend his deal by a further year, indicated Mourinho had been a big factor in his decision.
“This is the biggest club in the world and I am delighted to be a part of this amazing team,” he said. “To work with Jose Mourinho, who has won so many trophies in his time as a coach, is an opportunity not to be missed.
“I cannot wait to get started and to meet my new team-mates. I would like to thank everyone at Shakhtar Donetsk for everything they have done for me over the past five years.
“This is a very exciting time for me with my focus now fully on the World Cup with Brazil.”
Speaking to MUTV, Fred revealed his first introduction to Manchester United was when he played as the team on computer games.
He added: “At United, I’m looking to win titles, alongside my new team-mates and my new manager, win matches with the club and make history by achieving great things together.”
The 25-year-old joined Shakhtar from Internacional in 2013 and won three league titles in Ukraine.
Fred will join up with United’s squad for pre-season after taking a break following the World Cup in Russia.