Shell has finally stopped the leak from its faulty oil pipeline in the North Sea, ending the flow of oil undersea after 10 days of the worst oil spill in UK waters for a decade.

Divers closed a relief valve which was the source of a small secondary leak, discovered after the first major leak in the pipeline at the Gannet Alpha platform had been plugged last week. Government officials are now opening an investigation into how the leak occurred and whether the correct procedures were followed. They will also have to decide whether Shell should pay for government expenses incurred in the clean-up operation.

Shell now has to decide how to deal with the pipeline, which could still contain as much as 660 tonnes of oil with the potential for much more damage than the 218 tonnes of oil thought to have spilled into the sea already.

"Closing the valve is a key step," said Glen Cayley, technical director of Shell's exploration and production activities in Europe, based in Aberdeen. "It was a careful and complex operation conducted by skilled divers, with support from our technical teams onshore. But we will be watching the line closely over the next 24 hours and beyond."

The UK government has said a containment structure should be built over the affected part of the pipeline, to ensure that no more oil emerges as the pipeline is dealt with.

Cayley said removing the residual oil from the pipeline, which has been depressurised and is now held to the seafloor by "rock mattresses", would "take time". The company could not say how long, nor does it yet know the cause of the leak.

News of the leak's shutoff came late on Friday afternoon, as the Scottish government prepared to launch an investigation into how the spill occurred. The procurator fiscal will begin formal interviews next week with Shell staff, including divers, and others involved in the attempts to minimise the damage. Conservation groups have warned that marine life in the area could be harmed, and fishermen have been told to stay clear of the Gannet Alpha platform– 112 miles east of Aberdeen– and the surrounding area.

Shell has also been criticised for a lack of transparency, as the leak was first detected last Wednesday but not made public until last Friday night.

The marine coastguard has estimated that the oil on the sea surface covers about 6.7 sq km.

Shell is maintaining three vessels on site as it repairs the damage, with dispersants and specialised oil spill response equipment if needed.

Vicky Wyatt, senior oil campaigner for Greenpeace, said: "While we'll be keeping a careful eye on whether the leak really is plugged as Shell claims, it's obvious that the more we learn about what is supposed to be a gold standard operation, the more you worry whether Shell can be trusted to drill in the remote and fragile Arctic. Here in the UK, the government must now take the lead and immediately call a halt to all future applications for deep sea oil exploration, and in particular the wave of new licenses for the environmentally fragile region off the cost of the Shetlands."

Marine Scotland is continuing to send planes and vessels to survey the area around the leak, though government advisers take the view that the risk of serious damage to the environment and marine life is small.

Last year's BP spill in the Gulf of Mexico was estimated to be spilling up to 70,000 barrels a day, compared with the 1,300 barrels thought to have been released in the Shell spill. The Guardian has discovered that oil spills happen in the North Sea at the rate of about one a week, but most are minor.