Suppose Candidate 1 was declared the winner of the election to be the leader of the country. However, after he/she takes office, the results changed due to (maybe) a recount, court case, etc.
So, Candidate 2 actually won. Has this ever happened and what happened after that?
Note: It can be from any country, but the election needs to be of the leader of the country (President, Prime Ministers, etc.)