Record eight-time champions Germany were dominated in Saturday's match in Lucerne, although Sweden's task was made easier after German forward Carlotta Wamser was sent off - barely half an hour in - for swatting a ball away from the goal-line with her arm.
By that point Sweden were up 2-1 after goals from Stina Blackstenius and teenager Smilla Holmberg cancelled Jule Brand's early opener for Germany.
Fridolina Rolfö calmly slotted the penalty after Wamser's red card and substitute Lina Hurtig wrapped up the scoring late on to cap a miserable night for Germany, who conceded four goals for the first time in any Euro match, including qualifiers.
It was the first time Sweden beat Germany at the Euros and ensured they topped Group C with maximum points and avoided the possibility of facing World Cup champions and Euro 2025 favourites Spain in the semi-finals.
Sweden will face the runner-up of Group D in the quarter-finals, with Germany facing the team that tops that group. That will be France, England or the Netherlands.
France have six points and plays the Netherlands, who have three points along with defending champions England. England plays Wales, also on Sunday.
Germany and Sweden had already qualified for the knockout stages but the match was decisive for top spot in the group, with a draw being enough for Sweden thanks to a better goal difference.
In the day's other game, Natalia Padilla scored one goal and set up the others for Poland's first-ever Women's European Championship win, 3-2 over Denmark.
Neither team had any hope of emerging from Group C after losing their opening games.
Poland is appearing in the tournament for the first time and the Spanish-born Padilla got the country's first ever goal when she opened the scoring in the 13th minute, pouncing on a rebound to fire past Maja Bay Østergaard after Ewa Pajor's initial effort was blocked.
Padilla followed up by crossing for Pajor to head in the second in the 20th.
Denmark pulled one back through Janni Thomsen before the hour-mark when Kinga Szemik let her long-range effort slip through her fingers.
Martyna Wiankowska scored Poland's third against the run of play in the 76th when Padilla's attempted shot from Pajor's cross turned into a layoff for the substitute to fire in.