After a night in which it lost one key race after another, “12 Years a Slave” was named the best film of 2013 at the EE British Academy Film Awards, better known by the name of the body that gives them out, the British Academy of Film and Television Arts (BAFTA).

While “Gravity” was the night’s biggest winner with six BAFTAs, including Outstanding British Film and Best Director for Alfonso Cuaron, Steve McQueen‘s harrowing drama pulled out a surprising last-minute triumph. First Chiwetel Ejiofor won the Best Actor award to give the film its first honor of the night, and then the film itself took the big prize, Best Film.

The film won in a tough category that also included its chief Oscar competition, “Gravity” and “American Hustle,” as well as “Captain Phillips” and “Philomena.”

Also read: 5 Burning Questions as Oscar Voting Begins

Together with the film’s tie with “Gravity” for the top honor at the Producers Guild Awards, the BAFTA victory is another sign that “12 Years” could hold its own against the flashier “Gravity” in one of the most competitive Oscar races in more than a decade.

Cate Blanchett of “Blue Jasmine” won the awards for best actress. She was a prohibitive favorite for her role in the Woody Allen movie, as she is at the Oscars in two weeks.

Ejiofor’s award came after “12 Years a Slave” had lost in a number of races, including supporting actor, supporting actress and adapted screenplay. Oscar frontrunner Matthew McConaughey was not nominated in the Best Actor category, but Leonardo DiCaprio was considered a strong threat to win for “The Wolf of Wall Street.”

With its Best Director win and its victory in the Outstanding British Film category, “Gravity” seemed to be the likely winner going into the final award of the night. (Admittedly, the British-film prize rarely goes to the Best Film winner.) It had also won prizes for its music, cinematography, visual effects and sound.

Jennifer Lawrence of “American Hustle” and Barkhad Abdi of “Captain Phillips” were named the best supporting actress and actor.

The win for Lawrence came as a slight surprise, with Lupita Nyong’o of “12 Years a Slave” going into the BAFTA ceremony a narrow favorite to win over a field that also included Oscar nominees Julia Roberts (“August: Osage County”) and Sally Hawkins (“Blue Jasmine”).

Abdi, a non-professional who was found by director Paul Greengrass driving a limo in Minneapolis, beat fellow Oscar nominees Michael Fassbender (“12 Years a Slave”) and Bradley Cooper (“American Hustle”). The Oscar frontrunner, Jared Leto from “Dallas Buyers Club,” was not nominated.

“The Great Beauty” won in the foreign-language category, while “The Act of Killing” was named best documentary and “Frozen” was named best animated film. All three are Oscar nominees in those categories.

The original-screenplay prize went to “American Hustle,” and the adapted-screenplay award to “Philomena.” The latter award was the third consecutive loss for “12 Years a Slave” in a significant category, following the supporting categories in which Nyong’o and Fassbender didn’t win.

On the craft-awards side, in addition to the four awards for “Gravity,” “The Great Gatsby” won for production design and for costume design, “Rush” won for editing and “American Hustle” won for makeup/hairstyling.

The winner of BAFTA’s Best Film prize has gone on to win the Oscar for Best Picture for the last five years in a row, although the two groups had the same winner only five times in the 15 years before that.

In honorary awards, director Peter Greenaway won the award for Outstanding British Contribution to Cinema, while Helen Mirren took BAFTA’s highest honor, the Academy Fellowship.

The show took place at the Royal Opera House, Covent Garden, and was hosted by Stephen Fry, who described himself as “humbled, honored and, in the best sense of the word, paid to be here.”

Also read: Oscars: Oddsmakers List ’12 Years a Slave’ as Frontrunner to Win Best Picture

The winners:

BEST FILM: “12 Years a Slave,” Anthony Katagas, Brad Pitt, Dede Gardner, Jeremy Kleiner, Steve McQueen

OUTSTANDING BRITISH FILM: “Gravity,” Alfonso Cuarón, David Heyman, Jonás Cuarón

OUTSTANDING DEBUT BY A BRITISH WRITER, DIRECTOR OR PRODUCER: Kieran Evans (Director/Writer) “Kelly + Victor”

FILM NOT IN THE ENGLISH LANGUAGE: “The Great Beauty,” Paolo Sorrentino, Nicola Giuliano, Francesca Cima

DOCUMENTARY: “The Act of Killing,” Joshua Oppenheimer

ANIMATED FILM: “Frozen,” Chris Buck, Jennifer Lee

DIRECTOR: “Gravity,” Alfonso Cuarón

ORIGINAL SCREENPLAY: “American Hustle,” Eric Warren Singer, David O. Russell

ADAPTED SCREENPLAY: “Philomena,” Steve Coogan, Jeff Pope

LEADING ACTOR: Chiwetel Ejiofor, “12 Years a Slave”

LEADING ACTRESS: Cate Blanchett, “Blue Jasmine”

SUPPORTING ACTOR: Barkhad Abdi, “Captain Phillips”

SUPPORTING ACTRESS: Jennifer Lawrence, “American Hustle”

ORIGINAL MUSIC: “Gravity,” Steven Price

CINEMATOGRAPHY: “Gravity,”Emmanuel Lubezki

EDITING: “Rush,” Dan Hanley, Mike Hill

PRODUCTION DESIGN: “The Great Gatsby,” Catherine Martin, Beverley Dunn

COSTUME DESIGN: “The Great Gatsby,” Catherine Martin

MAKE UP & HAIR: “American Hustle,” Evelyne Noraz, Lori McCoy-Bell

SOUND: “Gravity,” Glenn Freemantle, Skip Lievsay, Christopher Benstead, Niv Adiri, Chris Munro

SPECIAL VISUAL EFFECTS: “Gravity,” Tim Webber, Chris Lawrence, David Shirk, Neil Corbould, Nikki Penny

BRITISH SHORT ANIMATION: “Sleeping With the Fishes,” James Walker, Sarah Woolner, Yousif Al-Khalifa

BRITISH SHORT FILM: “Room 8,” James W. Griffiths, Sophie Venner

THE EE RISING STAR AWARD (voted for by the public): Will Poulter