From the Document: "Vacancies in the membership of the U.S. Senate can occur as the result of the resignation, death, or expulsion of a Member, or the refusal of the Senate to seat a Senator-elect. Article I, Section 3, clause 2 of the Constitution originally vested the power of appointment to fill Senate vacancies exclusively with the state governors when the legislatures were in recess, with the state legislatures authorized to elect replacements to serve the balance of the term at their next session. The Seventeenth Amendment, ratified in 1913, provided for direct election of Senators and directed governors to issue writs of election to fill vacancies. It also authorized state legislatures to empower governors to make temporary appointments until successors can be elected. At present, 45 states authorize their governors to appoint a Senator to fill a vacancy until a replacement is elected. Five states, however, provide that Senate vacancies may be filled only by election."
CRS In Focus, IF11907
Congressional Research Service: https://crsreports.congress.gov/