Totti tied Baggio with a precise free-kick around a wall in the 30th minute of Roma's match at Bari, levelling the game at 1-1, then added a penalty in the 57th to equalise again at 2-2 and move past Baggio.
They were the 13th and 14th goals this season for the 34-year-old Totti.
Totti nearly had a hat-trick when Roma was awarded another penalty but his spot-kick hit the post.
Still, Roma went on to win 3-2 when Aleandro Rosi scored five minutes into added time.
Silvio Piola, who won the World Cup with Italy in 1938, tops the all-time list with 274 goals, followed by Gunnar Nordahl (225), Giuseppe Meazza (216), Jose Altafini (216), Totti and Baggio (205).
Among other active players, Juventus captain Alessandro Del Piero is tied with Gabriel Batistuta for ninth on the list with 184 goals. The 20 goals Del Piero scored when Juventus was in Serie B in 2006-2007 don't count toward his total.
Totti made his Serie A debut in 1993 at the age of 16 and has played his entire career with Roma, his hometown club.
Baggio played between 1986 and 2004.
Totti received calls to retire when he was struggling earlier this season but he has seemed rejuvenated since his former team-mate Vincenzo Montella took over as coach in February.
At the final whistle, Totti put on a T-shirt that read 'The King of Rome is not dead'.
"The King of Rome isn't dead and he'll never die," Totti said.
"I know what I can offer. I'm happy to have beaten another record and a champion like Baggio.
"Now I hope I can continue at this level."