What happened at the end of Code Geass R2?
This was all part or Lelouch's Zero Requiem plan. 


   The plan involved focusing all of the world's hatred onto the tyrannical Emperor of the world (Lelouch) and killing him, as part of their plan for world peace.


Suzaku agreed to ally with Lelouch after the Tokyo Settlement incident with the F.L.E.I.J.A., specifically after his one-sided conversation with Jeremiah Gottwald.


   The only Geass order Lelouch gave Suzaku was the order to "live" on. (During the event on Shikinejima Island where he is ordered to kill Lelouch, who was Zero at the time)