The ministry said the plane’s incursion was the first known violation of Japanese airspace by a Chinese plane since it began keeping records about 50 years ago. China considers the airspace its own, because it is laying claim to the islands that Japan has controlled for decades.

Tokyo lodged a formal protest with Beijing, which swiftly retorted that it was the Japanese who had encroached.

In Beijing, the Foreign Ministry spokesman, Hong Lei, said that the activities of the Chinese plane were “completely normal.”

“China requires the Japanese side stop illegal activities in the waters and airspace of the Diaoyu Islands,” Mr. Hong said.

The episode comes just ahead of Japanese elections in which conservatives pushing for a more robust military to counter China’s rise are in the lead.

For months, patrol ships from the two countries have sporadically faced off near the islands known as Senkaku in Japan and Diaoyu in China, exchanging protests over loudspeakers that each is infringing on the other’s sovereignty. Recently, Chinese ships have sailed near the islands more regularly in what analysts in Japan interpret as a new strategy by China, either trying to wear down Japan’s resolve or to use the patrols to bolster its claims that it is protecting the islands and therefore is in charge.

It was unclear on Thursday whether the plane’s flight might have been part of such a strategy. This week, China appeared to increase the pressure on Japan by sending a flotilla of navy ships near the islands, instead of the maritime surveillance ships it sent before.

Some analysts have said they consider the standoff more dangerous than separate conflicts Beijing is involved with over islands in the South China Sea because those pit China against countries less powerful than Japan, which has one of the world’s most sophisticated navies.

The episode was an embarrassment for the administration in Japan, already struggling in national polls, since radar systems failed to detect the Chinese surveillance plane on Thursday. The authorities in Tokyo became aware of its presence only after a Japanese Coast Guard ship spotted it near the islands.

The Coast Guard ship’s crew radioed the Chinese plane, “Do not intrude into Japanese airspace.” The aircraft’s crew responded, “This is Chinese airspace,” according to the Japanese public broadcaster, NHK.

By the time fighter jets reached the area from a base in Okinawa, the Chinese plane was gone, the Defense Ministry official said.

In Tokyo, Chief Cabinet Secretary Osamu Fujimura called the Chinese actions “extremely regrettable.” Gen. Shigeru Iwasaki, chief of Joint Staff of Japan’s Self-Defense Forces, said it was regrettable that the plane had entered Japanese airspace unnoticed. “We are going to make sure this does not happen again,” General Iwasaki said.

Kurt M. Campbell, assistant secretary of state for East Asian and Pacific affairs, told reporters, “We are encouraging all sides to take appropriate steps so that there will be no misunderstandings, no miscalculations that could trigger an environment that would be antithetical to the maintenance of peace and stability.”

Mr. Campbell, who was in Malaysia, also reiterated the Obama administration’s stance that the security treaty between the United States and Japan applies to “any provocative set of circumstances.”

The United States has not taken a position on the sovereignty of the islands.

The flare-up over the islands began when the Japanese government started considering buying some of the islands from a private Japanese owner, which it did this year. Japan said it hoped that would calm tensions by keeping the islands out of the hands of a hawkish Japanese politician, but China took the government’s move as provocation.

Hisako Ueno contributed reporting from Tokyo, and Bree Feng and Jane Perlez from Beijing.