Prime Minister Bob Hawke's Labor Party retained power in yesterday's national election, but with a diminished majority because of a surprisingly strong showing by the opposition coalition.

The colorful, popular prime minister will have to govern with a reduced, though comfortable, majority in the House of Representatives. Some of the 1.4 percent swing against Labor probably was caused by the record number of invalid votes, most of them believed to have been cast by Labor supporters.

More than half a million votes, 7 percent of those cast, were invalid mostly because voters did not complete every square on the complicated paper ballot designed to record preferences as well as first-choice votes.

The swing against Hawke and Labor also stemmed from a vigorous campaign by the opposition leader, former foreign minister Andrew Peacock, and apparently occurred in the last days of the seven-week-long campaign.

Final counting in a dozen closely fought races will not be complete for at least a week, but the Hawke government is likely to have an 86 to 62 majority in the House, giving the Peacock-led coalition of his own Liberal Party and the rural-based National Party a foundation from which it could rebuild sufficiently to win power in the next election.

Foreign policy was not a major issue in the election for the House of Representatives. Both Hawke and Peacock follow broadly the same policies, centered on support for the alliance with the United States and continuation of the ANZUS treaty, irrespective of whether New Zealand, under its new antinuclear government, remains in it.

But in the parallel election for the Senate, which has no direct say on who will govern Australia, nuclear disarmament became an important issue.

During the campaign, the lead singer of the rock group Midnight Oil, Peter Garrett, became the main candidate of the hastily formed Nuclear Disarmament Party, whose policy is to ban all nuclear ships from Australian waters, stop the mining and export of Australian uranium and close the U.S. bases here.

Boosted by Garrett's popularity with Australian youth, the new party made a strong showing. In the most populous state of New South Wales, the Nuclear Disarmament Party polled nearly 9 percent of the vote, most of it taken from the Labor Party, and effectively denied Labor the chance of controlling the new Senate.

During the campaign, Peacock attacked Hawke for his lack of definite policies, for refusing to spell out his views on a potential capital gains tax and for imposing a means test on recipients of government-funded old age pensions.

Peacock promised major changes in the Australian tax system, including adoption of income splitting for couples and a new national sales tax in conjunction with reductions in the heavy rates of income tax.

Hawke exploited his popularity -- polls consistently gave him a 70 percent or better approval rating -- and called on the electorate to trust him to lead responsibly for the next three years. Hawke got a mandate in yesterday's vote, but with only 48 percent of the electorate supporting his party, the mandate was a cautious one.

Hawke and the Labor Party thus failed in one of their key strategies. They had planned to use the prime minister's personal popularity and the country's improved economic conditions to give it such a large majority that the conservative coalition would be unable to bridge the gap in the 1987 election. The strategy aimed at winning a majority of at least 50 seats in the 148-member House.

Hawke also used two tactics that were unprecedented in an Australian election. Both went against him.

He announced the election nearly eight weeks before polling day, thus giving Peacock more than twice the usual three weeks of campaigning.

Hawke's second mistake was his acceptance of Peacock's challenge to a nationally televised debate just five days before the election.

In recent years, Australian prime ministers have refused to debate their opponents on the politically pragmatic grounds that such encounters can only help the challenger.

That certainly happened this time. By the evidence of opinion polls and the unanimous judgment of commentators, Peacock won the debate.

On the basis of opinion polls, about 4 percent of the electorate swung from the Hawke government to the opposition in the final days of the campaign, and the debate was the only major campaign event during that period.

Although Hawke's mandate was not as big as he had expected, the result confirmed his position as Labor Party leader and will be taken by him and his party as an endorsement of his policies.

By resisting demands from the left wing of his party for massive government spending on welfare and job programs, Hawke in his first term halved the inflation rate, forced the unemployment rate down from more than 11 to 8.5 percent and encouraged investment by domestic and foreign enterprises.