The entry ban will last for 18 months, according to Judge Romualdo Aguedo. This applies to four employees of the Spanish energy and oil company Repsol: the general manager of the La Pampilla refinery, Jaime Fernández-Cuesta, and three company directors - Renzo Tejada, Gisela Posadas and José Rey.
The four will not appeal the decision, according to their lawyers, who said the Repsol chiefs planned to cooperate with authorities while investigating the disaster.
Last week, Peruvian President Pedro Castillo declared an environmental emergency for coastal areas affected by the spill, calling it an "ecological disaster". The measure is to last 90 business days, Castillo said.
The ship was hit by waves caused by the underwater eruption that dumped more than 6,000 barrels of crude oil into the waters near the Ventanilla district of Callao, Peru's main port.
Oil has since been found in the sea and beach sand along the coast of Peru, including the islands of Pescadores and Puntas Guaneras.
"Crude oil spills are having a sudden and significant impact on the coastal marine ecosystem with a high biodiversity and a high risk to public health," the Peruvian government said in a statement last Sunday.
Peruvian Foreign Minister Oscar Maurtua last week asked Repsol to compensate fishermen whose livelihoods had been largely eliminated in the wake of the crash.
"Repsol oil spill in Ventanilla is the worst ecological disaster that has occurred in Lima in recent times and has caused severe damage to hundreds of fishing families. Repsol must compensate for this damage immediately," Maurtua said in a tweet.
A spokesman for Repsol denied that the company should take responsibility for the incident. Last week, Tine Van Den told Wall Bake to local radio station RPP that "we did not cause this ecological disaster and we can not say who is responsible."
The spokesman added that they had asked the Peruvian fleet if there was a tsunami risk at the time and if the unloading should continue. The Navy gave Repsol the green light to operate normally, Bake said.
She added that the company was committed to restoring the entire coastline to its original state. In a Sunday statement, Repsol said it has organized more than 1,350 "properly trained" people to clean up the sea and coastline affected by the spill.
CNN's Jose Armijo contributed to this report..