The assets are being sold to Finnish group Keele Oy for $640 million (462 million euros), and the deal means an almost doubling of the Finnish company's network of service stations.
Shell is redrawing its strategy for downstream activities in refining and the distribution of oil products and said in December it was thinking of selling the assets covered by the deal on Wednesday.
The aim is to focus on its vast refining centres such as one at Port Arthur in Texas in the United States and in Amsterdam in the Netherlands while turning away from small or isolated refining activities such as a facility at Gothenburg in Sweden.
Overall, Shell intends to reduce its refining capacity by 15.0 per cent and to reduce its footprint in the business of selling fuel significantly.
The British-Dutch company had said at the beginning of September that it was in exclusive negotiations with St1/Keele.
The Finnish company Keele is the majority shareholder in St1 which owns petrol distribution networks in Finland, Sweden, Norway and Poland.
Shell said: "All service stations together with the CRT (transportation) business will remain Shell-branded in both markets under a licensing agreement."
The deal covers 340 petrol outlets and a refinery at Gothenburg in Sweden and 225 stations in Finland and road haulage activities in both countries.
"This transaction is consistent with Shell's downstream strategy to reduce net refining capacity by 15 per cent, to reduce our marketing footprint, and focus the portfolio on profitability and growth potential," company spokesman Mark Williams said in a statement.
Keele also bought Shell's bulk fuels business in both markets and the Shell marine business in Sweden.
The sale is conditional on regulatory approval from competition authorities.
ST1's chairman of the board Mika Anttonen told AFP: "We simply are trying to make our basic sales operations more profitable. Sales have been too small in Finland and Sweden."
The purchase will nearly double the company's number of service stations in the region from about 650 to more than 1,200.
"We're buying the retail points so we can take a look at what is profitable and what isn't and then close the sales points that are not profitable," Anttonen said.