Rosenborg lost 2-1 at home to Ireland's Sligo Rovers in the first leg of the European competition's second qualifying round on Thursday. An own goal by the Irish goalkeeper led to the Trondheim team's scoring.
The club announced in a press release that the relationship between Rosenborg and Hansen was terminated with immediate effect.
Hansen, who also coached Norway's U-21 side, returned to Rosenborg in 2012, seven years after his first stint with the club ended following a string of poor results.
The 22-time Norwegian champions play Sligo Rovers in the return leg on Thursday.