West Ham twice squandered a lead against Newcastle and had to settle for a 2-2 draw that moved the team four points clear of the Premier League's relegation zone on Sunday.

With five games remaining, West Ham is inching closer to survival but could yet live to regret switching off to allow Jonjo Shelvey to score Newcastle's second equalizer in the 67th minute — just 92 seconds after Tomas Soucek reclaimed the lead for the visitors.

West Ham manager David Moyes threw his hands out in disgust after Shelvey dribbled his way through a gap in the defense and exchanged a one-two with Dwight Gayle before slotting home a low finish.

Newcastle's head coach Steve Bruce, left, and West Ham's manager David Moyes during the English Premier League soccer match between Newcastle United and West Ham United at St. James' Park in Newcastle, England, Sunday, July 5, 2020. (Owen HumphreysPool via AP)

Newcastle's head coach Steve Bruce, left, and West Ham's manager David Moyes during the English Premier League soccer match between Newcastle United and West Ham United at St. James' Park in Newcastle, England, Sunday, July 5, 2020. (Owen HumphreysPool via AP)

In-form forward Michail Antonio gave West Ham the lead for the first time at St. James' Park in the fourth minute, only for Miguel Almiron to make it 1-1 in the 17th by sliding in at the near post to turn in a low cross.

West Ham is 16th in the 20-team league, four points above two teams in the relegation zone — 18th-place Aston Villa and 19th-place Bournemouth.

Newcastle is almost certainly safe in 12th place.

West Ham's Tomas Soucek, right celebrates after scoring with West Ham's Declan Rice during the English Premier League soccer match between Newcastle United and West Ham United at St. James' Park in Newcastle, England, Sunday, July 5, 2020. (Owen HumphreysPool via AP)

West Ham's Tomas Soucek, right celebrates after scoring with West Ham's Declan Rice during the English Premier League soccer match between Newcastle United and West Ham United at St. James' Park in Newcastle, England, Sunday, July 5, 2020. (Owen HumphreysPool via AP)

More AP soccer: https://apnews.com/Soccer and https://twitter.com/AP_Sports