Britain and France – represented by Benjamin Thomas and Donavan Grondin – finished tied on 40 points, three behind Denmark, but silver went to Walls and Hayter by virtue of winning the final sprint at the end of the 200 lap race.
It gives Walls his second medal of the Tokyo Games after his omnium gold, and a first medal for his Manchester housemate Hayter, part of the team pursuit squad who finished seventh earlier in the week.
Britain had been well placed from the start of the race, leading after the fourth sprint, but gradually losing ground as France and then Denmark went on the attack.
It looked as though they were heading for bronze with 30 laps to go, trailing the French by nine points, but things changed as the Belgian pair of Kenny de Ketele and Robbe Ghys went on the attack.
That brought them right into the picture for bronze, but Britain responded and by catching their attack they moved into position to win the final sprint and with it nick silver.
Walls told the BBC: “I was just cooked at halfway. But we had a bit of gas at the end to finish it off.”
Hayter added: “We set out on the front to try to get a bit of a head start. I think my legs started to go first.”
Support The Yorkshire Post and become a subscriber today. Your subscription will help us to continue to bring quality news to the people of Yorkshire. In return, you'll see fewer ads on site, get free access to our app and receive exclusive members-only offers. Click HERE to subscribe.