The rule will apply to all subjects, says Education Minister Gustav Fridolin.
"If you feel that having girls and boys in the same class causes problems then the problems themselves must be addressed, not avoided by simply splitting the class up," Fridolin told SR Ekot.
The gender segregation ban will apply to all subjects and schools will be issued with guidance as to how to implement it into the curriculum.
"We have seen a number of reports from state school inspectors (Skolinspektionen) where girls and boys have been kept in separate classes for certain subjects for years at a time. We do not think this should be permitted," said Fridolin to SR Ekot.
It is currently acceptable to put boys and girls in different classes provided that the school ensures they receive an equal standard of teaching, reports news agency TT.
There are no statistics on the prevalence of gender segregation in Swedish schools, but there has previously been debate on whether schools should separate boys and girls for physical education classes.
In autumn 2016, several schools, including a number of Muslim schools, were reported to be separating boys and girls for gym class. Schools have justified the move by saying that it encourages girls to participate in the lessons.