TOKYO (Reuters) - Japan's parliament voted into law on Saturday a defense policy shift that could let troops fight overseas for the first time since 1945, a milestone in Prime Minister Shinzo Abe's push to loosen the limits of the pacifist constitution on the military.

Abe says the shift, the biggest change in Japan's defense policy since the creation of its post-war military in 1954, is vital to meet new challenges such as from a rising China.

But the legislation has triggered massive protests from ordinary citizens and others who say it violates the pacifist constitution and could ensnare Japan in U.S.-led conflicts after 70 years of post-war peace. Abe's ratings have also taken a hit.

The legislation "is necessary to protect the people's lives and peaceful way of living and is for the purpose of preventing wars," Abe told reporters after the bills were approved by the upper house. "I want to keep explaining the laws tenaciously and courteously."

Japan's ally the United States has welcomed the changes but China, where bitter memories of Japan's wartime aggression run deep, has repeatedly expressed concern about the legislation.

China's Foreign Ministry said the move was "unprecedented."

"We solemnly urge Japan to learn the lessons of history ... uphold the path of peaceful development and act cautiously in the areas of the military and security, and do more to help push regional peace and stability rather than the opposite," it said.

The bills, already approved by parliament's lower house, were voted into law by the upper chamber in the early hours of Saturday despite opposition parties' efforts to block a vote by submitting censure motions and a no-confidence motion against Abe's cabinet in the lower house. All were defeated.

A key feature of the laws is an end to a long-standing ban on exercising the right of collective self-defense, or defending the United States or another friendly country that comes under attack, in cases where Japan faces a "threat to its survival."

Thousands of demonstrators have rallied near parliament every day this week, chanting "Scrap the war bills" and "Abe resign." Large crowds were still protesting into the early hours of Saturday.

The protests have called to mind those that forced Abe's grandfather, Nobusuke Kishi, to resign 55 years ago after forcing a U.S.-Japan security treaty through parliament.

The revisions also expand the scope for logistics support for the militaries of the United States and other countries, and for participation in peace-keeping.

The changes still leave Japan constrained in overseas military operations by legal limits and a deeply rooted public anti-war mindset.

"Even if the constitution is revised, among the Japanese people no one is thinking of going to foreign lands for the purpose of exercising force," former defense minister Itsunori Onodera told Reuters in an interview earlier this week. "I think Japan will maintain that stance from now on as well."

  Critics, however, say the changes make a mockery of the pacifist constitution and deplore what they see as Abe's authoritarian mode of pushing for enactment of the bills.

Opposition to the legislation brought together both liberals keen to preserve Japan's pacifist principles and conservative critics of what they consider Abe's authoritarian tactics.

"The content, process and doctrine of the security bills ... risk reversing the path we have walked for the past 70 years as a country of peace and democracy," Yukio Edano, secretary-general of the opposition Democratic Party, told parliament's lower house ahead of the no-confidence vote against Abe.

Abe won a second three-year term as ruling Liberal Democratic Party (LDP) chief earlier this month and faces no immediate danger of being unseated, but voter distaste for the new laws could hurt the ruling bloc in an election next year.

"The people’s revolt will continue toward the next election one way or another," said Keio University professor Yoshihide Soeya.