The left-handers' stand of 19 spanned 69 balls after England had been in desperate trouble when all-rounder Paul Collingwood, the last of their recognised batsman, was out for 74 after a gutsy innings lasting nearly five-and-three-quarter hours.
Collingwood's exit left England on 233 for nine but the 10th-wicket duo held firm as England ended the match on 252 for nine.
The teams now head to Lord's, where Australia have not lost a Test since 1934, for the second match in this five-Test series starting on Thursday.
When Collingwood was eventually out, caught at the second attempt in the gully by Michael Hussey off aggressive fast bowler Peter Siddle, having faced 245 balls with six boundaries, it seemed England had lost all hope of avoiding a convincing defeat.
There were a minimum of 11.3 overs remaining when Anderson and Panesar came together.
But both left-handers demonstrated a defensive technique worthy of top-order batsmen although England let themselves down by sending on their physiotherapist and 12th man in a blatant attempt to waste time.
Apart from Collingwood, no other top-order batsman made more in the second innings than England captain Andrew Strauss's 17.
Each ball England Anderson and Panesar survived was cheered to the echo by the crowd at what was the first Test match ever played in Wales.
And when Anderson steered Siddle through the slips for four it meant Australia would have to bat again to win the match.
England had let the game get away while making 435 in a first innings where three batsmen, Collingwood included, got past fifty but did not go on to a hundred.
Australia then showed England how to bat on a slow pitch by piling up 674 for six declared.
For the first time Australia scored four hundreds in the same Test innings against England with captain Ricky Ponting (150), Marcus North (125 not out), Simon Katich (122) and Brad Haddin (121) all reaching three figurest.
Australia's progress was first checked Sunday by a determined eighth-wicket stand of 62 lasting 81 minutes between Collingwood and Graeme Swann.
But when Swann - who made 47 not out in the first innings - was plumb lbw to Ben Hilfenhaus for 31, after missing an attempted pull, England were 221 for eight and the game seemingly over.
The sight of Australia spearhead and left-arm quick Mitchell Johnson bowling wides with the new-ball gave England fans hope that the draw, which had seemed for beyond their side's reach at 70 for five, was coming into view.
England, at lunch, had been 102 for five.
Collingwood was 35 not out and all-rounder Andrew Flintoff unbeaten on 11.
After lunch, they both looked to be getting down to the task at hand.
But a stand of 57 was ended when Flintoff fell on 26 to the first ball he faced after the drinks break.
England's 2005 Ashes hero opened the face of his bat against Johnson and was caught low down at second slip by Ponting.
Stuart Broad, who survived a close lbw appeal from Johnson first ball, was plumb lbw to Nathan Hauritz for 14 as the off-spinner, much-maligned before the start of this match, took his third wicket of the day and sixth of the Test.
Earlier, star batsman Kevin Pietersen had taken his overnight score from three to eight when, trying to leave a delivery from Hilfenhaus, he got into an awkward position and was bowled off-stump.
Hauritz, a ball after being cut for four by Strauss, got a delivery to turn and bounce away from the left-hander who edged behind as he attempted another cut and was well caught by wicket-keeper Haddin for 17.
England, already in trouble on their overnight score of 20 for two, were now, at 46 for for four in dire straits only for the most unlikely batting heroes to deny Australia victory.