Financial details were not disclosed but British media reports said Newcastle paid £39 million ($50.13 million) for the 25-year-old England international.
"It's an amazing club and for me it's a massive opportunity to come and be involved in a successful team that's doing exciting things," Barnes said.
"I think it's an attacker's dream to come into a team like this, it's high-paced, it's physically demanding, but you can see the rewards of that with the chances and the goals scored, so I think I'll certainly suit the style."
Barnes came through Leicester's academy and was one of the few bright sparks for the club last season, but was unable to help them avoid relegation despite netting 13 times in the Premier League.
He has made one appearance for England, coming on as a substitute in a 3-0 friendly win over Wales in 2020.
"He is strong, quick and very good technically, and he showed last season in particular that he has an eye for goal from wide positions," Newcastle manager Eddie Howe said of Barnes.
"He will add a different element to our play and we look forward to working with him as we prepare for the season ahead."
Newcastle qualified for the Champions League for the first time in 20 years last season after finishing fourth.