TOKYO, OCT. 26 -- Former Japanese prime minister Yasuhiro Nakasone said today that he has accepted an invitation from Iraq to visit Baghdad next week to discuss the Mideast crisis with Iraqi President Saddam Hussein and seek the release of hostages held there.

Nakasone, whose reputation here has been scarred by a stock scandal, could barely control his excitement as he announced the trip at a Tokyo news conference. But diplomats and other politicians here were worried that the 72-year-old political veteran might be playing into Saddam's hands.

"We are not asking Mr. Nakasone to" make the trip, Foreign Ministry spokesman Taizo Watanabe said in chilly tones this afternoon. "He is volunteering to do it. . . . We have to be concerned about the goals of {Saddam}."

The Iraqi president has been trying to woo leaders and ex-leaders of various countries to negotiate with him in an effort to undermine the international alliance opposing Iraq in the Persian Gulf crisis. Secretary of State James A. Baker III this week complained that Saddam is engaged in "shameless shopping of hostages."

Former British prime minister Edward Heath visited Iraq this week and returned with 38 freed British hostages. Austrian President Kurt Waldheim made a similar trip to Baghdad several weeks ago, with similar results.

There are at least 139 Japanese hostages still in Iraq, according to the Foreign Ministry, and their fate gets significant press attention here. But the Japanese government, sensitive to international charges that it is not pulling its weight in the alliance against Iraq, has refused invitations to negotiate over the Japanese captives.

Nakasone's trip could be an embarrassment to the government here because he holds an unusual public position, wielding influence in the ruling party even though he is no longer a member.

Nakasone's recent career has been somewhat akin to that of his friend Ronald Reagan. Like Reagan, he had a highly successful tenure at the head of the government, retiring in 1987 with such great popularity that he was able to pick the next prime minister. And like Reagan, Nakasone has seen his popularity and public esteem fall since he left office.

Not long after leaving office, he was implicated in a big stock-and-bribery scandal and had to resign two years ago from the nation's dominant party, the Liberal Democratic Party.

Today he serves as a low-seniority independent member of the lower house of the parliament, or Diet, but unofficially, he still has considerable influence in the Liberal Democratic Party.

Moreover, Nakasone has experience in dealing with Iraq.

During the 1973 Arab oil embargo, a disastrous blow to Japan because of its nearly total dependency on imported oil, Nakasone was serving in the cabinet as minister of international trade and industry. Working with special envoy Takeo Miki, Nakasone traveled to the Middle East and helped make deals that gave Japan a renewed supply of oil while other countries still faced the embargo.

That precedent, suggesting that Japan might break with the Western allies and strike a separate deal with Saddam, is worrying Nakasone's fellow politicians here.

"I'm not sure about the wisdom of his timing," said Kazuo Aichi, a veteran foreign-affairs expert in the Diet. "I have a feeling this whole thing was stimulated by Mr. Heath's trip. . . . If it is only an effort to get back the Japanese hostages, that would be awful."

Prime Minister Toshiki Kaifu, whose own status within the Liberal Democratic Party is not strong enough to prevent Nakasone from going, said he finds Nakasone's plan "satisfactory." "After I talk with him, I will decide how I feel about this," Kaifu said.

Nakasone said today he will ask Saddam to return all hostages in Iraq, not just the Japanese. But he went on to note that he has received letters from Japanese hostages in Iraq and their families here asking him to intervene for them.

"I feel some kind of destiny here," Nakasone said. "I thought Japan should not any longer take an outsider position."