Conan O'Brien is losing "The Tonight Show" but he'll be getting a $32.5 million consolation prize courtesy of NBC ... sources tell TMZ.

In return, we've learned Conan has agreed to sit on the bench until September. Translation -- he can't host another show until the fall.

In addition to the $32.5 mil, we've learned NBC is also paying severance to Conan's "Tonight Show" employees. In all, we're told NBC's payout is around $40 million.

But Conan probably won't see close to the $32.5 mil. Under the deal, any money Conan makes during the remaining contract period with NBC will offset the network's obligation. So, if Fox were to make a deal with Conan and pay him $25 mil during the NBC contract period, Conan would only score $7.5 mil from NBC.

One well-placed NBC source told us something surprising -- looks like NBC may keep its intellectual property rights. So Conan can't take his creations -- such as Triumph the Insult Comic Dog and the Masturbating Bear -- to his next gig.

We're told the Conan/NBC deal still isn't completely done, but it's very close.

