I never understood the movie Donnie Darko. In order not to keep the question vague, what happens in the end?
Basically what happens is
I think it is a mistake to take the events of Donnie Darko literally, including the ending.
The main character Donnie is developing schizophrenia. The schizophrenia causes Donnie to believe he is at the center of a time-travel adventure that just might save the universe.
The movie shows how this hallucinated fantasy would unfold if it were reality. So the ending isn't intended to bring the movie to a realistic conclusion or even to make sense.
In an extra scene on the DVD, Donnie is having a conversation with his father and says, "Dad, I'm crazy."
Personally, I think part of the genius of Donnie Darko is that -- just like many real-life schizophrenics' hallucinations -- Donnie's fantasy almost starts to make sense if you strain to understand. But ultimately it only really makes sense to Donnie.
The movie shows an alternate timeline that diverts from the real timeline. Donnie Darko should have died in the beginning, but he avoided it, because he was lured out by Frank. The movie is about Donnie Darko learning about the theorie of alternative timelines.
The key element that some of the other answers miss is that Donnie makes a choice when he discovers how the whole alternative universe and weird timeline stuff actually works.
In the timeline that takes up most of the movie, his actions and choices result in the death of someone he loves (not strictly his fault, but wouldn't have happened if he had made other choices). But the book from Roberta Sparrow taught him that he could change this timeline, so he chooses an alternative where he dies but his girlfriend survives.
So the key to interpreting what happens is that it is, somehow, a redemptive self-sacrifice. That is, at least, what it feels like.
It appears that the film tells the following story:
Originally there was only one Universe - the Primary Universe, where all mankind was living.
At some point in time an "Incident" had happened "when the fabric of the fourth dimension became corrupted and a Tangent Universe was created. There is no indication in the film when this Incident had happened. It may have happened early in the beginning of the film, or at some point prior the events that the film starts with.
As the Book reads, the Tangent Universe is highly unstable and it can sustain life for no longer than several weeks. Apparently, all mankind from the Primary Universe unbeknownst got trapped in the Tangent Universe. After the Tangent Universe expires, it will collapse upon itself, forming a black hole withing the Primary Universe, thus destroying all the mankind.
According to the Book, after a Tangent Universe has occurred, an Artifact may appear. In the film the Artifact was a jet engine that came from the Primary Universe into the Tangent Universe through a portal (gateway) at the Tangent Vortex.
Donnie Darko, now in the Tangent Universe, is chosen to be the Living Receiver with a task "to guide the Artifact into position for its journey back to the Primary Universe". Donnie must accomplish this task before the Tangent Universe expires. If he does not, then all mankind will be destroyed when the Tangent Universe collapses. As the Living Receiver, Donnie is blessed with Fourth Dimensional Powers, most important of which is the ability to create Time Portals (wormholes) - gateways between Universes, that work as a time machine.
Donnie is not aware of his task and his abilities and he discovers them as the film progresses.
People who live around Donnie work as the Manipulated Living, unconsciously assisting Donnie in different ways in his task of returning the Artifact to the Primary Universe.
In addition, Donnie is having visions of Frank that also provide some guidance. In the film Frank is a boyfriend of Donnie's sister Elizabeth, who made himself a rabbit costume for Halloween. What Donnie sees in his visions is not actions of the actual Frank who came back through some sort of time travel, but rather hallucinations that occur because of Donnie's ability of foresight as the Living Receiver. As the Book reads, the Living Receiver is often tormented by terrifying dreams, visions and auditory hallucinations during his time withing the Tangent Universe.
Donnie's girlfriend Gretchen and the actual Frank unconsciously work as the Manipulated Dead. Their task is to create an Ensurance Trap that will leave Donnie no choice but to return the artifact and thus to save all mankind.
After Gretchen is killed in the Tangent Universe, Donnie realizes that there is only one way to save her. By this time he has realized his task and his abilities. Donnie creates a Time Portal (wormhole) between the Universes through which the jet engine returns into the Primary Universe and all mankind is transfered back from the Tangent Universe into the Primary Universe, just before the Tangent Universe has collapsed.
Just before Donnie travels from the Tangent Universe he says: "Going home", and laughs. Then, in his letter to Roberta Sparrow he says: "I hope that when the world comes to an end, I can breathe a sigh of relief, because there will be so much to look forward to". Then we see Donnie laughing in his bed in his home. So, he was glad that he had accomplished his task and saved the mankind. Then he peacefully turns on his side smiling. This suggests that Donnie did not expect the jet engine to crash on him in the Primary Universe, he expected to live on, and thus his act was not a self-sacrifice.
As to all other people, as the Book reads: "when the Manipulated awaken from their Journey into the Tangent Universe, they are often haunted by the experience in their dreams. Most of them will not remember. Those who do remember the Journey are often overcome with profound remorse for the regretful actions ..."
There are a lot of logical problems with this story. Gretchen and Frank are killed in the Tangent Universe, then they are transfered back in time into the Primary Universe along with all other people. How do they become live again in the Primary Universe? Technically Donnie did not return the Artifact into the Primary Universe but instead has sent there a jet engine from another plane. There was no apparent need to kill Frank. Does the Primary Universe become empty when the Tangent Universe is created, is everything transfered from one Universe into another, or only people are transfered and why? Et cetera ...
In my view - a very illogical story and an overrated film.