One of the most interesting things about Denis Villeneuve's "Blade Runner 2049" is its subversive ending, which upends protagonist K's perception of himself.
K believes himself to be Rick Deckard's son and the first-ever child born of a replicant — Rachael from the original "Blade Runner." K finds Deckard in the ruins of Las Vegas.
Deckard explains that he abandoned his child with Rachael at an orphanage because they were being hunted. K had childhood flashbacks earlier when he investigated the orphanage.
In the flashback, K hid a wooden horse in a furnace. Years later, he finds the toy in the same furnace, leading him to believe he's more than a replicant — he's the chosen one.
However, this turns out to be false, as K learns that Rachael's child was a girl. He then realizes that Ana, a doctor and memory designer for replicants, is Deckard's child.
Ana illegally implanted her own real memories in K. While he's disappointed with the truth, K rescues Deckard from replicant enforcer Luv, killing her in the process.
Since it looks like Deckard has perished in the crash, it's safe for K to take him to see his daughter. Outside Ana's lab, K lies down on the snowy steps, succumbing to his wounds.
K's end is ultimately a sad yet noble one. While he wasn't the messianic replicant child he believed he was earlier in the film, K was still able to be a hero by the story's end.