There are two answers to this question.
Tom Baker played the Doctor for 7 seasons (not counting his cameo at the very end of Pertwee's last season). That remains the record in terms of seasons.
In terms of years as the "current" Doctor, that distinction is shared by Sylvester McCoy, who was the "current" Doctor from 1987 to 1996, and by Paul McGann, the "current" Doctor from 1996 to 2005, or 9 years (roughly) each.
A case could be made that if you include the various Big Finish audio drama seasons, then McGann, who has played the Doctor in audio on a regular basis since about 2002, is the overall record holder.