The deal also includes an option for a sixth season.
"Daniel is an exciting young winger with lots of skills, vision, exceptional pace and a good work ethic," United manager Ole Gunnar Solskjaer said. "He had a great season with Swansea City and has all the attributes needed to become a Manchester United player.
"We are delighted he has signed with our club and we are all looking forward to working with him. This is the perfect environment for Daniel to continue his development."
Reports suggest that United will pay Swansea an initial £15 million for the 21-year-old and that the overall fee could rise to £18 million based on performance-related add-ons.
"This is one of the best days of my life and a challenge I am really looking forward to," James said. "The Premier League is the best league in the world and Manchester United is the perfect place for me to continue to develop as a player."
James recorded four goals and seven assists for Swansea in the Championship last season.