The patrol boat was on regular duty in the Yellow Sea, the ministry said, which abuts the Korean peninsula on the west. It noted the shells landed about 200 meters (650 feet) from the boat. No injuries or damage was reported.
"We fired back several rounds of shells," a ministry official said.
The incident comes after South Korea's navy fired warning shots Tuesday at three North Korean patrol boats that crossed the Yellow Sea maritime border into South Korean territorial water.
North Korea called Tuesday's action a "deliberate grave provocative act," and its KCNA state news agency warned South Korea would face military attack "without any warning at the moment" North Korea "detects any trifle provocation."