The surplus stood at 32.9bn yen ($394m; £248m), the Ministry of Finance said. In January the deficit came in at 1.5tn yen.
Japan has had to increase energy imports, as most of its nuclear reactors remain shut.
Analysts said this was not necessarily a sign of a swing to surplus for Japan.
“The trade data was a positive surprise as falls in exports were smaller than expected,” said Taro Saito from NLI Research Institute in Tokyo.
“But it is too early to conclude the trade balance has returned to a surplus trend.”
Overseas shipments fell 2.7% in February from the year earlier, the data showed. Most forecasts were for a drop of 6.5%. Imports rose 9.2% from the previous year.
The improving health of the US economy has contributed to increased demand for Japanese goods.
“Exports to the United States are growing and we have seen signs that the US economy has hit a bottom, so this is a positive sign for Japan’s exports,” said Shuji Tonouchi from Mitsubishi UFJ Morgan Stanley Securities in Tokyo.