Vokes, signed in the summer by Wolves from Bournemouth, came off the bench to give a youthful Wales side a deserved victory in their opening World Cup qualifier.
Before the 18-year-old’s close-range winner, Wales had toiled to break down an ultra-defensive Azerbaijan side who had Brazilian-born forward Fabio Luis Ramim sent off.
The one thing Wales could not have afforded was to lose this match ahead of Wednesday’s much tougher trip to Russia.
But when Jason Koumas saw a penalty, and his follow-up volley, saved in the second half, it looked like Wales were going to be denied a victory their industry and confidence merited.
Wales opened their bid to qualify for South Africa 2010 fielding a side which included five players still eligible for the under-21s, with Wolves youngster David Edwards given the chance to stake a claim for a central midfield role.
The five players in question now have over 50 senior caps between them, and this was the acid test of Toshack’s largely enforced youth revolution.
Toshack’s reign has been one of constant change, and Edwards’ inclusion in an attacking midfield role for his sixth cap was at the expense of veteran Carl Robinson, a fixture in the team for four years.
Azerbaijan’s new boss, the German legend and former Scotland manager Berti Vogts, was in charge for his first competitive match.
Wales started with pace, enthusiasm and plenty of neat passing.
A cross delivered by Koumas from the right was plucked from the head of Edwards by goalkeeper Kamran Agayev, then Joe Ledley drove wide from 18 yards.
Tottenham’s Gareth Bale surged past three men on a fine run into the box before being blocked, he felt, unfairly.
Azerbaijan replied with a 25-yard effort from Branimir Subasic, saved well by Wayne Hennessey before another effort from the same player flew over the bar.
Sasha Yunisoglu was booked for pulling back Earnshaw, with Wales continuing to move forward as teenage Spurs full-backs Bale and Chris Gunter surged down the flanks at every opportunity.
But the visitors to Cardiff were a much better side than Wales had encountered in their four previous meetings with Azerbaijan, who managed only one draw and three defeats in those games.
Ramim was a constant threat but Wales went close after 28 minutes when Bale’s free-kick deceived Agayev with Earnshaw almost reaching the loose ball. Gunter then had the rebound scooped from his toes a yard out.
Two minutes later Agayev made a stunning flying save to touch away a 30-yard strike from Koumas. Edwards then eased himself into a shooting position on the edge of the box and saw his left-footed effort curl just off target.
The promise was there from Wales but the cutting edge was missing.
Clearly Craig Bellamy would have been a quality asset, but he will not be available until the October games with Liechtenstein and Germany.
Azerbaijan sent on Agil Nabiyev for Djavid Huseinov at the break, with Ramim booked for using his elbow on Bale after 48 minutes, which other referees may have considered a red-card offence.
The Macedonian official, Aleksandr Stavrev, then seemed to compound the error by demonstrating exactly what he had punished.
Azerbaijan were increasingly content to sit deep and defend in depth, inviting Wales to open them up. But this was one of those days when Koumas could not find the telling passes.
Bale was booked for taking a free-kick too quickly, a split second before the referee’s whistle.
Frustrating was creeping in, mistakes being made without pressure as Wales looked for inspiration.
Toshack took off Earnshaw after 61 minutes, sending on the more physical Ched Evans.
Then Koumas was booked for stupidly kicking the ball high into the empty seating after a free-kick was harshly awarded against him.
Worse was to follow after 66 minutes when Gunter was brought down in the box by Rashad Sadikhov and Koumas stepped up for the penalty.
He saw his first effort blocked by Agayev, who then did well to catch the follow-up.
Azerbaijan were reduced to 10 men a minute later when Ramim was booked for pulling back Koumas.
The referee at first looked to not realise it was the forward’s second booking, but eventually the red card was produced.
Next into the book was Huseinov, before Wales sent on Vokes for Edwards, another forward, as they searched for the breakthrough.
Wales pressed forward with growing desperation, and Vokes saw a fine header from Bale’s cross saved brilliantly by Agayev, who was booked for an obscure offence only seen by referee Stavrev.
But from the resulting corner Wales finally got their goal.
Bale’s corner curled into the box and Vokes and Ashley Williams both went for it.
The ball broke in the six-yard box for Gunter to lunge in and Vokes to finally crack the ball home from a couple of yards.
With two minutes to go, Robinson was brought on in place of Koumas.