SHANGHAI – China said it had posted its first quarterly trade deficit in seven years, despite a narrow surplus in March, as rising commodity prices pushed manufacturers' costs higher.

China recorded a small trade deficit of $1.02 billion for the first quarter, its first since the beginning of 2004. But analysts said a large trade surplus was expected for the full year as its exports tend to grow later in the year.

"China's demand is strong and the prices of bulk commodities are high currently, but the situation won't last as China's exports usually go up in the second half of each year," UBS economist Wang Tao told Dow Jones Newswires.

Exports rose 26.5 percent on year in the first quarter and imports were up 32.6 percent on year.

The quarter's trade deficit was due to the strong rise in imports, the General Administration of Customs said in a statement.

"The value of imports in the first quarter hit a record high for the first time of more than $400 billion," the customs administration said.

For the month of March, China bounced back to a $140 million surplus after posting a $7.3 billion-trade deficit in February -- its first since March 2010.

February's slowdown was typical of China's festive season, when factories ease off -- and in most cases close -- after cranking up production before the Lunar New Year holiday.

March exports rose 35.8 percent from the same month a year earlier, up from February's 2.4 percent rise.

Imports rose 27.3 percent, up from 19.4 percent in February. Rising prices for raw materials helped push up the value of imports.

The March surplus caught analysts by surprise. A Dow Jones poll of 13 economists had forecast a median monthly deficit of $4.0 billion for March.

In 2010, China posted a $7.24 billion deficit in March, as companies stocked up on imported raw materials, many of which were later processed into goods for export. For the full year, China posted a $183.1 billion surplus.

Analysts said the quarterly trade deficit suggested China was making progress in rebalancing its export-reliant economy.

"The rebalancing is happening. It's only a matter of time," BNP Paribas economist Isaac Meng told Dow Jones, adding rising import prices were eroding the surplus while domestic inflation was raising export prices.

Washington, one of the harshest critics of Beijing's trade policy, acknowledged in March that China was taking steps to boost imports.

US Treasury Secretary Timothy Geithner said last month that China had no alternative but to shift its growth strategy towards relying more on domestic growth as demand weakens in the US and Europe -- but added it needed to do more.

China is planning to cut tariffs on imports as it seeks to boost domestic demand, state media has reported.

The state-run China Daily quoted Vice Commerce Minister Zhing Shan last month as saying not only would the government cut tariffs, but it would also relax some restrictions on importers.