People across Japan cast ballots on Sunday to choose local leaders and assembly members as well as two Lower House lawmakers.
National parties campaigned fiercely, framing the poll as a bellwether for the Upper House election in the summer.
NHK projects that Prime Minister Shinzo Abe's Liberal Democratic Party will lose both by-elections.
In Okinawa, a candidate who opposes the government's plan to relocate a US military base won. Freelance journalist Tomohiro Yara is backed by five opposition parties and a local party in Okinawa.
He defeated Aiko Shimajiri of the LDP. Shimajiri is supported by the LDP's coalition partner, Komeito.
The Okinawa electoral district includes the planned relocation site for the US Marine Corps Futenma Air Station. The Japanese and US governments want to move the base from a densely populated area to a less crowded coastal district.
They say that's the only way to reduce safety hazards for nearby residents while maintaining the deterrence of the Japan-US alliance.
But Okinawa Governor Denny Tamaki opposes the plan and wants the base to be moved out of the prefecture altogether.
The by-election was held to fill the Lower House seat vacated by Tamaki when he ran in last year's gubernatorial election.
Yara said, "Relocating to Henoko will not lead to a solution. It's high time we considered a more realistic approach."
In Osaka, Fumitake Fujita of Nippon Ishin is projected to win. The party is advocating what's known as the "Osaka metropolis plan."
It would abolish Osaka City and reorganize it into special wards just like Tokyo. Nippon Ishin says their plan will cut costs by streamlining overlapping city and prefectural services.
Fujita said, "I will do my utmost to achieve administrative reform for Osaka and to open a new chapter in politics."
Prime Minister Abe and senior LDP officials went to Osaka to campaign for their candidate, but have likely failed to retain the party's seat.
LDP's Secretary-General Toshihiro Nikai said, "We humbly accept the results, will analyze why we lost, and prepare for future elections.
Senior officials of the opposition parties say they will step up cooperation to counter the ruling coalition in the coming Upper House election.
On Sunday, people across Japan also voted in 721 elections to choose mayors and local assembly members.