London: Although his record-breaking wicket clinched victory for England over India, what meant most to James Anderson was that his retiring teammate Alastair Cook was on the field to witness it.

Anderson became the most successful fast-bowler in Test history by claiming the final wicket in England's 118-run fifth test win at the Oval on Tuesday.

The 36-year-old Anderson bowled Mohammed Shami for his 564th career wicket, passing Glenn McGrath for fourth on the all-time list and leaving himself only trailing spin bowlers, as England wrapped up a 4-1 series victory.

Despite Anderson's moment of glory, it was his long-time teammate Cook — playing in his 161st and final Test — who led England from the field, having set up the victory with a second innings century that left India chasing a record 464 to win.

"It was (perfect)," Anderson said. "Happy that Cookie was on the field to see that wicket. It's been a tough week."

Centuries from Lokesh Rahul and Rishabh Pant threatened what looked like a simple victory, but England took five wickets after tea to end No. 1-ranked India's second innings on 345.

Adil Rashid removed both centurions, before Sam Curran struck twice to set the stage for Anderson.

"What Jimmy's achieved and what he's capable of achieving still is astounding really," England captain Joe Root said. "For him to have taken as many wickets as he has, to even be in the same league as McGrath and now chasing the big two spinners is a phenomenal effort."

India made a good start after beginning the day 58-3 before Ajinkya Rahane and Hanuma Vihari were lost in consecutive overs to leave it facing defeat on 167-5 at lunch.

That was despite Rahul's first Test century since December 2016, which was reached with three boundaries in one over against Ben Stokes. It was the first time an Indian opening batsman had gone past 50 in the series.

Rahul's runs at first seemed consolatory but a comeback victory then appeared realistic when Pant, India's 20-year-old wicketkeeper, hit a six off Rashid shortly before tea for his maiden Test century.

That left India needing 166 runs in the final session to reach what would have been a record chase of 464.

"We did sort of think about (winning)," India captain Virat Kohli said. "But we knew that these guys had to be in there until the (required) score got below 100 and then we'd probably have a chance and England were waiting for someone to get out and then take the new ball."

Despite already having the new ball available to him, Root persisted with Rashid, who had bowled a wicket-less and costly 10 overs.

He was rewarded when the leg-spinner got the breakthrough with a stunning delivery which turned from outside leg-stump to clip the top of Rahul's off-stump, ending his innings on 149.

Also Read—India vs England: We played better cricket than what the scoreline reads, says Kohli

"It was a brilliant delivery," Root said. "Rash has that in him. That's why we have him in the side because he has the ability to change games, to turn situations like that on their head and thankfully got us in a position where we could then go on and win the game."

Pant went for another six in the next over but was caught on the boundary at long-off by Moeen Ali, giving Rashid his second wicket in 12 deliveries and turning the match back in England's favor.

Curran then had Ravindra Jadeja (13) and Ishant Sharma (5) caught behind, before Anderson toiled away — in a 14-over spell either side of tea — without reward.

He had been denied Jadeja's wicket when wicketkeeper Jonny Bairstow dropped a tough chance to his left, but ultimately the landmark came in the most fitting style.

Anderson uprooted Shami's middle stump to ensure the wait for his wicket — and an England victory — was over.

While it was Cook who led the side off the field, he didn't see that as a reflection of who has been England's most important player during his 12 years playing alongside Anderson.

"I think he's England's greatest cricketer," Cook said of Anderson. "Just the way he's constantly kept going. It's just a phenomenal effort and god knows how many he's going to end up with."