China will respect the will of the Libyan people and hopes for a return to stability in the war-torn country, China's Foreign Ministry said on Monday, as Libyan rebel fighters clashed with government forces in Tripoli.

China respects the choice of the Libyan people and hopes that the situation there will quickly return to stability and that people's lives can return to normal, Foreign Ministry spokesman Ma Zhaoxu said.

Libyan government tanks shelled parts of central Tripoli on Monday after rebels swept into the heart of the city and crowds took to the streets to celebrate what they saw as the end of Muammar Gaddafi's four decades in power.

China is willing to work with the international community to play a positive role in rebuilding Libya, Ma said in a brief statement on the ministry's website (www.fmprc.gov.cn) that avoided reference to Gaddafi or the rebels' National Transitional Council.

But China's official news agency Xinhua was more forceful in asserting that Gaddafi's time had come, referring to the clashes in the capital as the final push against Gaddafi and his forces' obviously miniscule resistance.

Although it remains unclear where Gaddafi is now and how he is to react, it is clear that the scale of victory has tipped heavily in the rebels' favor, Xinhua said in an English-language report released just before the ministry's statement.

Beijing had been stepping up engagement with rebel leaders in recent months, even as it said those meetings were part of an effort to encourage a negotiated end to the six-month old civil war.

China, which generally avoids entangling itself in nations' domestic affairs, invited both rebel leaders and the Libyan foreign minister for nearly back-to-back talks in Beijing in June.

During the talks in Beijing, China praised Libya's rebel National Transitional Council as a major political force in Libya and an important dialogue partner.

Those talks and later meetings with senior Chinese foreign ministry officials in the rebel stronghold of Benghazi have marked something of a practical policy adjustment for China, concerned about its investments in the country.

About half of China's crude oil imports last year came from the Middle East and North Africa, where Chinese companies have a big presence.

Rebel leaders promised last week to honor China's business contracts in the country and requested China's help in rebuilding Libya once they ended Gaddafi's rule, Xinhua reported.

China did not use its U.N. Security Council veto power in March to block a resolution that authorized the NATO bombing campaign against Gaddafi's forces, but it quickly condemned the strikes and repeatedly pushed for compromise between his government and rebels.