Japanese Prime Minister Junichiro Koizumi has pledged to push on with economic and political reforms, despite the results of the weekend's elections.
Mr Koizumi seems to be losing his golden touch
The Liberal Democratic Party (LDP) won 49 seats out of 121 being contested in the upper house - two short of its modest target of 51.
The opposition Democratic Party (DPJ) made big inroads, winning 50 seats.
The ruling coalition has retained its upper house majority, but the LDP loss is likely to weaken Mr Koizumi.
It is only the second time that the LDP has been outnumbered by an opposition party in an upper house election, according to Kyodo news agency.
BBC Tokyo correspondent Jonathan Head says the prime minister will now face emboldened enemies within his own party, and an opposition with a real chance of forming the next government.
Katsuya Okada, new leader of the DPJ, is popular with women voters
Final results released on Monday showed the LDP won 49 seats, one fewer than its 50 up for re-election, while New Komeito gained one seat to take it to 11. This gives the ruling coalition 139 of the 242 seats in the upper house.
The DPJ, in contrast, gained 50 seats, up from the 38 it previously had. It made its gains mainly at the expense of smaller parties.
Chief Cabinet Secretary Hiroyuki Hosada described the result as a "very severe verdict" for the government, but Mr Koizumi dismissed suggestions that he step down.
"There would be no need for that," he told national television network NTV. "As long as we can keep control of both houses, we will continue with our reform policies," he said.
End of the affair
Mr Koizumi, 62, came to power promising bold economic reform that would revitalise the Japanese economy. Critics say those reforms have fallen far short of success.
His plans to privatise the Japanese post office, in effect the world's biggest savings bank, have run into strong resistance from within his own party, where conservative factions have traditionally benefited from ties to the state sector.
And his attempt earlier this year to restructure the overstretched national pension scheme ran into trouble when it emerged that he and other politicians had avoided making payments into it for years.
His reform of the banking sector has been more successful, but perhaps too complex for voters to appreciate.
Japan's wider economy is doing much better this year, but that has been credited to growth in neighbouring China and to restructuring by Japanese companies, not to Mr Koizumi.
A survey by Japan's largest newspaper, the Yomiuri Shimbun, indicated that support for the prime minister had fallen to 35.7%, the first time it has dropped below 40% since he took office.
Our correspondent says that now he no longer looks like a vote winner, the conservative factions who have borne much of Mr Koizumi's criticism may start seeking alternatives.