The company, Pluspetrol, was asked to leave by the government after the death of a demonstrator in Junin province, during four days of violent protests.
The demonstrators, mostly indigenous people, accused the company of contaminating local rivers and soil.
Pluspetrol denied causing any environmental damage.
It said it had met all legal requirements for exploratory work, including getting consent from more than 2,000 farmers in the area.
The company said it would remove its remaining equipment from the area, known as Block 108, near the municipality of Pichanaki in the coming days.
A spokesman denied the company was being forced to leave, saying it was going because it had finished its work in the area.
He said the company had met all legal, environmental and social requirements for exploratory work in the block, including securing consent from farmers and communities.
Pluspetrol started exploratory activities in Block 108 last year with the approval of the government.
Energy and Mines Minister Eleodoro Mayorga said he believed the company had complied with its contract but was asking it to leave the block so that the government could evaluate its activities.
On Tuesday, a crowd of protestors stormed a military base being used by Pluspetrol as a storage area.
They were driven back by police firing tear gas but a 25 year-old man was killed and 20 injured, police say.
Reuters news agency says the interior ministry is investigating the illegal use of firearms by police during the demonstrations.
Pluspetrol is also struggling to end conflicts in the northern Amazon, where indigenous protestors have taken control of oil wells and stopped output in the country’s biggest oil block.
Protests and demonstrations have continued for a decade in Peru in many areas of the country where foreign oil companies are prospecting and mining for oil and minerals.