However, the win was not enough, as Everton beat Bournemouth at Goodison Park, and Dean Smith's side have therefore been relegated to the Championship alongside Southampton and Leeds United, ultimately finishing two points behind the 17th-placed Toffees.
Leicester were Premier League champions in 2015-16, but they will now play in the second tier of English football for the first time since the 2013-14 campaign.
West Ham, meanwhile, have finished the season in 14th position in the table, but they can secure a spot in the 2023-24 Europa League by winning the Europa Conference League final against Fiorentina on June 7.
Leicester had the game's first half-chance in the 14th minute when the ball broke to Kelechi Iheanacho outside the West Ham box, but the striker could only drag his attempt wide of the post.
Daniel Iversen then had to make a smart save down the other end to deny Michail Antonio, but Leicester, as expected, were the team pressing, and Youri Tielemans then curled one over the crossbar in the 18th minute.
Fornals was next to try his luck for the visitors, looping one just wide in the 20th minute, before West Ham goalkeeper Lukasz Fabianski did well to keep out a strike from Barnes in the 25th minute.
Leicester came so close to making the breakthrough three minutes later when Iheanacho unleashed a powerful strike inside the box, but his effort clipped the top of the crossbar.
Kiernan Dewsbury-Hall sent one high of the West Ham crossbar in the period that followed, with Leicester carving out another opportunity though smart play in the final third.
The home side managed to make the breakthrough in the 34th minute of the match through Barnes, who played a one-two with Iheanacho before finishing into the bottom corner of the net.
James Maddison swept one just wide of the West Ham goal in the 36th minute, and Leicester looked far from a team that were in serious danger of down into the second tier of English football.
Jonny Evans headed just wide of the away side's goal in the 52nd minute, with the Foxes looking to double their advantage in the early stages of the second period.
Said Benrahma came close to levelling the scores just before the hour when he struck one from distance, but the post came to Leicester's rescue.
The home side doubled their lead in the 62nd minute, with Faes finding the bottom corner with an excellent header from a Tielemans free kick, but the celebrations were slightly muted due to the news that Everton had taken the lead against Bournemouth.
Fornals did manage to halve the deficit in the 79th minute, with the Spaniard racing onto a pass from Ings before finding the back of the net with a smart finish.
News of a potential Bournemouth leveller at Everton continued to filter around the stadium, but there was no goal from the Cherries heading into the final stages of their clash at Goodison Park.
There were 10 minutes of additional time in the game on Merseyside, but there was to be no late shock in that match, with Leicester being relegated to the Championship at the end of a disastrous season.No Data Analysis info