Germany, the Olympic champions, had not conceded a goal in the tournament so far as they coasted into the last eight.
Sweden, though, produced a resolute display at Roazhon Park to come from behind following Lina Magull's acrobatic goal in the 16th minute.
Sofia Jakobsson equalised after latching onto a long pass up field in the 22nd minute, before Stina Blackstenius' close-range header put the Scandinavians ahead early in the second half.
Germany pressed for an equaliser and saw a Video Assistant Referee turn down a penalty for a marginal offside, with Lena Oberdorf and Marina Hegering then both heading late chances wide.
Sweden, who have never won the World Cup, will go on to face Holland, who earlier beat Italy 2-0, in Lyon on Wednesday.
Germany had started brightly and broke the deadlock in the 16th minute.
Paris St Germain midfielder Sara Dabritz stole possession just inside the Sweden half and drove forwards, chipping a pass into the penalty area. Bayern Munich's Magull flicked the ball up before beating goalkeeper Hedvig Lindahl with an acrobatic volley.
Sweden, though, produced a swift response after defender Linda Sembrant sent a long clearance up field, which bounced over the German defence and was collected by her Montpellier team-mate Jakobsson.
The forward powered into the penalty area and drilled a low drive past Almuth Schult into the bottom left corner.
Because of the searing temperature at Roazhon Park, the teams were given a cooling break just after the half-hour.
Sweden soon threatened again when Blackstenius made the most of a slip by a German defender to race clear, with her angled drive pushed over the bar by Schult.
At the start of the second half, Germany midfielder Dzsenifer Marozsan came on for her first appearance since suffering a broken toe in the opening group match, replacing Linda Dallmann.
It was Sweden, though, who were in front after 48 minutes. Fridolina Rolfo's header was saved by Schult but Blackstenius was alert to knock the loose ball in from close range.
Blackstenius almost added a third when sent clear down the left and cutting inside, only to slip in the penalty area.
With 15 minutes left there was another cooling break, before Germany felt they had a penalty claim after Alexandra Popp collided with the Sweden keeper when jumping for a header.
Following a lengthy VAR review, referee Stephanie Frappart signalled play to continue as Popp was ruled to have been marginally offside in the build-up.
Germany continued to press for an equaliser, with Oberdorf heading wide after the Sweden keeper failed to connect with a cross from the right.
During stoppage time, Hegering sent her header at the back post over as Sweden closed out a famous victory.
Follow Sporting Life on social media - find us on Facebook here or tweet @SportingLifeFC
Related Women's World Cup links