The deal was signed by electricity and water utility ONEE and Shell, a ministry statement said, without disclosing financial terms of the transaction.
The gas will be transported from Spanish ports initially, using a gas pipeline that links the two countries, until Morocco builds its own LNG terminals, the ministry said.
The LNG will help ONEE operate two power stations in northern and eastern Morocco that used to operate on Algerian gas sent through the same pipeline.
Algeria unilaterally decided in 2021 to halt gas flows to Spain via Morocco through the pipeline. Rabat said it would reverse the flow in 2021 by importing LNG from Spanish terminals.
ONEE is aiming to increase the share of gas in Morocco's electricity mix to meet low-carbon goals, the ministry said.
Renewables represented 18% of Morocco's total electricity production last year while gas accounted for only 1.6% and coal 72%, official figures show.
By March 2023, renewable energy represented 40% of the country's installed capacity, with Morocco planning to increase that to 52% by 2030.
Reuters, the news and media division of Thomson Reuters, is the world's largest multimedia news provider, reaching billions of people worldwide every day.Go to: https://www.reuters.com/