It was Levski's first league loss since former midfielder Kostov, 48, took charge of the 26-times Bulgarian champions in November.
"Levski didn't perform according to my expectations and we didn't achieve the results, which I expected when I took over," Kostov said. "Therefore I decided to quit."
Levski, considered title and cup favourites, were also knocked out of the Bulgarian Cup in a 2-1 extra-time defeat at Lokomotiv Plovdiv earlier this month.
Kostov replaced Georgi Ivanov, who resigned following the 1-0 defeat by bitter city rivals CSKA Sofia and was under immense pressure to win Levski's first league title since 2009.
Kostov coached teams in Cyprus, Armenia and Ukraine in the last decade and won the Cypriot Cup with Anorthosis Famagusta in 2002 and led Metalurg Donetsk to the Ukrainian Cup final in 2010.
Financially-stable Levski are third in the standings with 45 points from 20 matches, three points behind leaders CSKA, who also changed their coach this month.
A few weeks ago, Levski signed a sponsorship deal with Russian investment bank VTB Capital, whose parent group owns Russian club Dynamo Moscow.
"Our dream is to see Dynamo and Levski playing in the European Super Cup final," said VTB's Deputy President Yuri Soloviev.
Levski have already begun their search for a new coach with local media reporting Stanimir Stoilov, who guided the team to the UEFA Cup quarter-finals in 2006 and to the Champions League group stages the following year, is the favourite to replace Kostov.
"There's no need to worry," Levski owner Todor Batkov said. "We'll have a meeting tomorrow and we'll decide who'll succeed Kostov."
"I can't confirm anything about Stoilov but I don't want to deny this information either."