On loan from the Los Angeles Galaxy for three months, the England midfielder scored Milan's fourth goal, finishing off a slick move with a powerful shot.
Brazil's Kaka, who rejected a world record move to Manchester City last week, scored twice - a penalty and a shot from the edge of the box.
Milan's other goal was scored by veteran Dutchman Clarence Seedorf.
Milan got off to the worst possible start when Serie A top scorer Marco Di Vaio scored a ninth-minute penalty but Carlo Ancelotti's side soon drew level when Seedorf slid the ball home after Kaka's effort was parried.
Kaka then took control of the game, netting with a penalty and a superb left-foot shot, before Beckham wrapped up Milan's win.
"To score my first goal is great and I will keep this shirt, but the important thing is we won here," said Beckham, who is due to return to LA Galaxy on 9 March.
"I can't say what will happen," added Beckham, responding to growing speculation he might stay in Italy. "Even if my contract says that I'll be here until March. We'll have to see."
Milan coach Carlo Ancelotti added: "Our hands are tied because he has a clear contract.
"We can't do anything to change things, he can definitely do something. He must sort out his contract with the American team. I'm a realist - we'll take advantage of him for now."