The 39-year-old finished with 6-43 -- 11-136 in the match -- to help Sri Lanka dismiss Pakistan for 114 after they were set a target of 136 to win on the fifth and final day at Sheikh Zayed Stadium.
Herath's dismissal of last batsman Mohammad Abbas was his 400th wicket in his 84th Test, becoming the 14th most successful bowler and fifth spinner in the five-day format to reach the milestone.
Herath was delighted at reaching the milestone.
"I'm so happy with the remarkable achievement of 400 wickets," said Herath after the match. "All credit should go to the people behind me, from my parents to the team and the supporting staff."
More From This Section
Herath, who took 5-93 in Pakistan's first innings of 422, admitted there was help from the pitch on which 16 wickets fell on the last day.
Herath took 23 wickets against Pakistan in 2014 -- a world record in a two-match series, and he said he had no clue why he was continually so successful against the nation.
"I have no idea. I've played nearly 20 Tests, maybe that's why," he said.
He is the second Sri Lankan to take 400 or more wickets behind Muttiah Muralitharan who is the highest wicket taker in all Test cricket with 800.
He also became the fourth fastest to the milestone behind Muralitharan (72 Tests), New Zealand's Richard Hadlee (80 Tests) and South Africa Dale Steyn (80 Tests).