The citizens vote for the candidates that they want to represent them in the Riksdag. The Riksdag then chooses the Prime Minister. The Prime Minister, in turn, appoints the government ministers. How this is done and when various steps in the formation of a new government actually take place depend on the election result.
The election result is preliminary until the votes have been re-counted, which takes about a week. However, the Prime Minister can announce in the days following the election whether he intends to remain in office or to resign, based on the preliminary election result.
Below follow three possible scenarios that could arise after the elections.