Police and fire crews were called to the scene after the lorry, carrying hay bales, caught fire just before midday between junctions 13 for Stroud and 14 for Thornbury.
The fire has now been put out and the northbound carriageway reopened.
But the southbound carriageway will stay closed overnight to allow repairs to take place, Highways England said.
The agency said signed diversions were in place, and advised road users to plan ahead and allow plenty of extra time for their journeys.
Drivers travelling south have faced delays of at least 30 minutes as they approached the area, before joining diverted traffic.
An HE spokesman said: "The fire is out now and has been thoroughly damped down.
"But, the road surface under the vehicle has been badly damaged, so there will be work going through the night to repair that."
He added it was hoped the southbound carriageway would be fully reopened in time for the rush hour on Monday.
Gloucestershire Fire and Rescue said four appliances were called in to tackle the blaze which involved 42 tonnes of hay.
Posting from the scene on Twitter, West Mercia Police assistant chief constable Chris Singer, said: "Smoke still billowing on M5 southbound road totally closed both ways near Stroud this could last a long time I think!"
A lorry fire forced the closure of the M5 motorway in both directions in Gloucestershire.