A ruling backed by eight of the 12-judge Supreme Court panel had earlier declared that a decision by President Jose Mario Vaz to appoint Baciro Dja by presidential decree violated the constitution.
"The president of the republic has just informed me the Supreme Court has declared my appointment as prime minister unconstitutional," Dja told journalists after meeting the head of state.
"Consequently, I resign the office. I'm going to my office to formalise my decision."
These including properly consulting the ruling party and listening to the opinions of other parties in parliament, it said.