Over 98 percent of mail-in ballots filed by Massachusetts voters in the Sept. 1 primary election were deemed valid and counted, according to data released by the Secretary of the Commonwealth William Galvin’s office on Tuesday.

Mail-in ballots accounted for more than 47 percent of the total vote in a primary that saw a record 1.7 million votes cast — a turnout rate of 36.6 percent. The state rejected 17,872 of those mail-in ballots, meaning that 98.3 percent of mail-in ballots that were returned were ultimately deemed valid, and counted.

The most common reason for rejection was that the ballot arrived after the 8 p.m. deadline on Sept. 1 — which happened with 8,419 ballots.

Of the other rejected ballots, 3,547 were deemed invalid because they were missing the envelope, or the envelope was unsigned. Another 1,771 ballots were rejected because the voter was found to have already voted, and 78 because the voter was no longer registered — or deceased.

Voters in all but three of Massachusetts’ 351 cities and towns took advantage of mail-in voting for this election, with 814,013 mail-in ballots cast in all.

Galvin has said he expects more than 3 million votes to be cast in the Nov. 3 general election. If mail-in voting proves similarly popular, that would mean 1.4 million votes would be cast by mail.