EAST PROVIDENCE, R.I. (WPRI) — The Massachusetts state primary is about three weeks away. The primary will decide who represents the Democratic and Republican parties in key races, like the governorship, attorney general, secretary of state, and state legislature seats.

Here’s what you need to know to cast your ballot on Sept. 6:

Massachusetts residents have until Aug. 27 to register to vote in the primary.

Massachusetts residents can vote by mail for any reason. To receive a mail-in ballot, an application is required. The deadline to apply for a mail-in ballot for the primary is 5 p.m. on Aug. 29.

Voters can apply for a mail-in ballot online, by mail, email, or fax. To vote in the primary, you must identify which party’s ballot you want to receive in the mail.

Applicants will then receive a ballot by mail. The ballot must reach your local elections office by 8 p.m. on Election Day (Sept. 6). Even if the ballot is postmarked on or before that day, if it doesn’t arrive at the elections office in time, it will not be counted.

Mail-in ballots must be delivered through the postal service or dropped off at secure drop boxes, early voting locations, or local elections offices. Voters cannot drop off mail-in ballots on Election Day.

Early voting will be available from Aug. 27 through Sept. 2.