Costa rose highest to emphatically head home Fernando Tissone’s 60th minute corner to shock Milan, and give the visitors all three points at the San Siro for the first time since March 2008.
Milan were frustrated by a resilient Sampdoria side in the opening 45 minutes, failing to click sufficiently in the final third.
Their makeshift frontline of Robinho and youngster Stephan El-Shaarawy looked ill at ease, thrust together after the Rossoneri sold leading lights Zlatan Ibrahimovic and Antonio Cassano this summer.
Massimiliano Allegri chose to start new signing Giampaolo Pazzini on the bench and that seemed a questionable decision with Sampdoria well-organised and confident in possession, having secured promotion back to Italy’s top flight last term.
Robinho went close with a free kick just before the half-hour mark but, aside with Mario Yepes’ header flying over the bar from the resulting corner, there was little else to trouble Sergio Romero in the Sampdoria goal.
Allegri’s men attempted to claim a penalty ten minutes before that passage of play, but it was a sign of desperation with Robinho’s corner striking the arm of Daniele Gastaldello – a clear case of ball to hand rather than the other way round.
Sampdoria had the better of the chances in the first half, with Brazilian striker Eder looking lively up front.
He held off the challenge of Daniele Bonera when chasing down a long ball out on the left flank, with the Italian defender just recovering in time to prevent Eder fashioning a strike at the Milan goal.
Shortly before the break, Andrea Costa floated the ball into the box from the left, but Eder was unable to make sufficient contact to test Abbiati and a low drive shortly afterwards was comfortably held by Milan’s shot-stopper.
Both sides increased their tempo in the opening exchanges of the second-half, with Robinho lively, forcing Romero into a good save with a curling 52nd minute effort.
Yet the home fans were growing increasingly impatient, and Allegri introduced Pazzini for the ineffectual El-Shaawary and Urby Emanuelson for Robinho to freshen up his side’s attacking options.
Instead, that had the opposite effect, as Costa’s header on the hour gave Sampdoria the lead.
Milan almost equalised six minutes later but Romero managed to claw Mario Yepes’s downward header, from a Mattia De Sciglio corner, onto the post and then expertly gathered the rebound off it.
Then, deep into injury time, Kevin-Prince Boateng’s 30-yard deflected strike cracked against the Sampdoria post and Mathieu Flamini’s low shot was hacked off the line.
But with the hosts unable to convert those opportunities into goals, a lack of attacking quality in and around Sampdoria’s penalty area ultimately proved costly for Milan.
It means they begin the new Serie A season with defeat and plenty of questions still hanging over the club’s transfer activity.