Douglas Luiz and Leon Bailey scored during more than a quarter of an hour of stoppage time as Aston Villa came from behind to beat Crystal Palace.
Substitute Jhon Duran equalised for Villa in the 87th minute after Odsonne Edouard had put Palace ahead two minutes into the second half.
But Villa then completed the turnaround during the added time.
Luiz converted from the penalty spot after a lengthy video assistant referee review when Ollie Watkins was brought down by Chris Richards, and Bailey turned in from close range as Palace threw bodies forward in pursuit of an equaliser of their own.
Palace were without manager Roy Hodgson in the dugout because of illness, with assistant Paddy McCarthy taking charge.
The win moved Villa up to seventh, two points ahead of eighth-placed Palace, who were denied a first triumph at Villa Park since 2013.
Persistence pays off for Villa
It appeared Villa were going to pay for their profligacy after Watkins spurned two big chances either side of half time - Sam Johnstone saving in the first period before he was denied by the post in the second.
Villa dominated possession in the opening 45 minutes but, Watkins' opportunity aside, they struggled to break down a well-organised Palace backline.
Palace caught them cold soon after the restart and Mateta was the architect. He used his physicality to turn on the halfway line before bursting down the flank and delivering an early ball into the path of Edouard, who capitalised on a slip from goalkeeper Emiliano Martinez to coolly slot home for his fourth in the league this season.
Despite being without England international defender Marc Guehi and midfielder Jefferson Lerma because of injury, Palace appeared to be on track for a rare win at Villa Park, standing firm in the face of relentless pressure.
However, substitute Duran rifled home the equaliser in spectacular fashion to turn the game on its head and drag momentum back in Villa's direction.
A desperate lunge from Richards saw Watkins fouled in the area and spot-kick specialist Luiz made no mistake from 12 yards to edge his side in front.
Bailey - another substitute - gave Villa some breathing space in the 101st minute when he was found in space by Moussa Diaby.
"We played a lot [of other matches] like today and were winning in the first 20 or so minutes," Villa manager Unai Emery told BBC Match Of The Day.
"We said at half-time to keep going and controlling the game like we were doing. They have a very good team and good players and they did that transition and scored the goal. Then it was a difficult moment.
"We were playing more with our hearts than with our minds in the last 20 minutes and sometimes you need that. At the end we deserved to win. We scored three goals so I'm very happy because after their goal it was a difficult moment and we really reacted very well."
Villa now turn their attention to the Europa Conference League with a trip to Polish club Legia to come on Thursday.
Palace relying heavily on Edouard
Hodgson returned for his second spell in charge of Palace in March and was key in steering the club clear of relegation, but they couldn't rely on his pitchside instruction at Villa Park.
Palace confirmed shortly before kick-off that the 76-year-old "had taken ill" and that assistant McCarthy would take the reins alongside Ray Lewington.
It seemed as though Edouard was going to raise Hodgson's spirits by delivering all three points but the Frenchman lacked support from others in attack when Palace had further chances to strengthen their lead.
Eberechi Eze was denied on two occasions by Villa goalkeeper Martinez, while Mateta struggled to have much impact after laying on the assist for the opener.
"I'm disappointed for the players - the gameplan worked for a large spell of the game, but I'm disappointed that we didn't get anything from the game," McCarthy said.
"The team shape and the effort were great. We knew it was going to be a tough side, but the boys who stepped in were great.
"The result just leaves a really bitter taste in our mouths."
Edouard appears to be filling the void left by Wilfried Zaha, who departed for Galatasaray this summer, and has scored four of Palace's six goals in the league this campaign.
The former Celtic striker has also surpassed his tally of three goals in the Premier League in 2022-23.