Here's what happened:
* Megatron was defeated and captured by the Autobots: Megatron was ultimately defeated by Optimus Prime in a climactic battle, and he was then imprisoned within the Allspark.
* Megatron's fate is left ambiguous: While it is shown that the Allspark is destroyed, Megatron's fate is never explicitly stated in the film. This leaves the possibility that he survived.
* Megatron returns in the sequel: Megatron does indeed return in the 2009 sequel, *Transformers: Revenge of the Fallen*, confirming he survived the destruction of the Allspark.
So, while Starscream did attempt to betray Megatron, he did not succeed in killing him.