Williams also scored a drop goal in the first half, giving Warrington the advantage at half-time.
Saints' first half scores came from a try from Conrad Harrell, with John Bennison adding to the score and scoring the home side's only points with a penalty after the break.
Saints were beaten hard by two fast-break tries, but it was at the start of the second period that the visitors won the game and had a chance to return to Wembley for the first time since winning the cup in 2019.
The first was a stunning one-handed finish into the left corner from Ashton, one of the great tries by a winger.
With his entire body facing the opposite side of the touchline, he snaked his looped left arm but still managed to control the ball and touch it down with his fingertips.
Wire then scored a third try from Wrench, also scored by Thewlis. Front-row forward Harrison then fell to safety, Matt Dufty zinged his way through and man-of-the-match Williams scored the winning goal.
It was a second successive defeat for Saints, who were unable to recover from last week's Super League defeat to leaders Catalunya Dragons, with manager Paul Wellens set to face struggling Hull FC without a manager this Friday. warned that it would consider major changes.
St Helens manager Paul Wellens:
“We're in the Challenge Cup quarter-finals and for a team that normally faces challenges in big games, we've got the opposite result.
“We haven't learned any lessons from last week. It's very disappointing and very humbling. I expected us to react, but we didn't. We looked at ourselves a little bit. It needs to be fixed.”
“We need to consider what options are available.The responsibility for continuing to wear the uniform lies with those wearing the uniform, but as long as we are at this club, there are standards that are required when wearing the uniform.'' They need to understand that.”
“I want them to sting me and hurt me over the next few days. If they don't hurt me, then I'm in the wrong club.”
Warrington head coach Sam Burgess:
“That was Matty Ashton's try, but he's been working really hard on that.
“It's not just a fluke. On Saturday, he was practicing 50 or 60 reps. He was practicing on the mat. For the young kids watching, it's a sign that practice pays off. It shows that.
“We were good but we still have a little bit left. Overall it was a great team performance. But I'm pretty relaxed. It doesn't really mean anything now.”
“It's not easy to come here and win, but some of the players are disappointed in the moments they didn't get. We're not riding high. In patches. We are playing well, but we can improve.”
St Helens: Wellsby. Makinson, Harrell, Blake, Bennison. Dodd Lomax. Walmsley, Clark, Delaney, Sironen, Batchelor, Knowles.
Interchange: Matautia, Mbie, Bell, Whitley.
Warrington: Dufty. J. Thewlis, King, Wrench, Ashton. Williams, Hayes. Harrison, Walker, Philbin, Nicholson, Fitzgibbon, Crowther.
Interchange: Brock, Holroyd, Powell, Wood.
Referee: Jack Smith.