A federal judge said General Motors is not required to pay $450 million to cover medical benefits for retirees, in a defeat for the United Auto Workers union.

In a 36-page decision, U.S. District Judge Avern Cohn in Detroit said on Tuesday that the post-bankruptcy GM did not assume any obligation for the payment, which the automaker had contracted to make two years before its June 2009 Chapter 11 filing.

The payment had been part of a June 2007 contract between the old GM, its former Delphi Corp affiliate and the UAW.

(Read more: Barra broke glass ceiling, but real challenge is ahead)

It was not, however, included in a different contract over medical benefits signed in July 2009 by GM after it emerged from Chapter 11.

The UAW claimed that the new GM owed the money by virtue of Delphi's own emergence from bankruptcy in October 2009.

Cohn, nonetheless, said the language of the 2009 contract made clear that GM did not owe the payment.