Mr Costa, who is said to be a target in related investigations, announced the decision in a televised statement after a meeting with President Marcelo Rebelo de Sousa.
According to news agency Reuters, Mr Costa said that his conscience was clear but he would not run for the post of Prime Minister for the fourth time.

Portuguese Prime Minister Antonio Costa resigned on 7 November, hours after his chief of staff was arrested in a corruption investigation. Photo: Reuters
The President of Portugal will now have to decide whether Costa’s Socialist Party, which has a majority in Parliament, should be allowed to form a new government or dissolve Parliament and call elections.
Socialist Party President Carlos Cesar said his party was prepared for any scenario, while Luis Montenegro, leader of the main opposition Social Democratic Party, said he was ready for early elections.
Mr Montenegro stressed: “There is no need to waste any more time waiting for the government to collapse.”
Political scientist Adelino Maltase said, “It is inevitable that this will be followed by elections.” Antonio Costa Pinto, an expert at the University of Lisbon, also does not rule out the possibility that another socialist prime minister will take over the government, but says early elections are the most likely option.
The prosecutor’s office had earlier said that five people had been detained in the investigation, including Mr Vitor Escaria, Prime Minister Costa’s chief of staff.
Infrastructure Minister Joao Galamba, who previously held the post of Energy Minister, and Nuno Lacasta, president of the APA environment agency, are the main suspects and will appear in court, according to a statement from the prosecutor’s office.
Prosecutors are investigating allegations of bribery and retail influence over investments in a lithium mining concession in northern Portugal, a hydrogen plant project in the port of Sines and a big data center there.
The prosecutor said the suspects used Mr Costa’s name and authority to circumvent procedures related to the deals and the Supreme Court would consider Mr Costa’s possible role in the case. Mr Costa also said he was willing to cooperate with the justice system