* Oz benchmark's first weekly decline after five weeks of gains
* Firmer oil prices lift energy stocks
* Gold stocks buck upward trend (Updates to close)
By Nikhil Subba
Sept 27 (Reuters) - Australian shares ended higher in subdued trade on Friday, led by gains in energy stocks, on rising optimism about a U.S.-China trade deal, but the market clocked its first weekly decline in six weeks.
The S&P/ASX 200 index .AXJO rose 0.6%, or 38.5 points, to close at 6,716.10. The benchmark, however, marked its first weekly decline since the week ended Aug. 23, closing 0.2% lower. The index closed 0.5% lower on Thursday.
China's commerce ministry said Beijing and Washington are still discussing details of upcoming trade talks in October, and making preparations to ensure "positive progress" is made during the negotiations, stoking hopes that the two sides would find a way out of their near 15-month old trade war. atmosphere around the trade spat also turned lighter after U.S. President Donald Trump on Wednesday told reporters the two sides were having "good conversations" and that an agreement "could happen sooner than you think." China is Australia's largest trading partner, domestic stocks are particularly sensitive to developments on the Sino-U.S. trade front.
"Markets are cautiously optimistic ... there are some signs the trade resolution could be certainly moving in the right direction," said James Tao, a market analyst at CommSec.
"There's no major indication that we are necessarily going to reach a deal or be closer to a deal, but that's just the market's interpretation of what we've seen from both sides."
The energy index .AXEJ gained about 1% at close, hoisted by firmer oil prices over concerns of a Middle East conflict disrupting supply. in the oil and gas space Woodside Petroleum WPL.AX and Santos Ltd STO.AX each ended about 1% higher.
The technology .AXIJ and utility sub-indexes .AXUJ advanced more than 1% each. Energy infrastructure firm AusNet Services Ltd AST.AX rose nearly 2%, while logistics software maker Wisetech Global WTC.AX closed 2.3% up.
Australia and New Zealand Banking Group ANZ.AX was top gainer among the "Big Four" lenders, which were all trading higher, helping the financial subindex .AXFJ rise about 0.5%.
The broader mining index .AXMM finished 0.3% higher, as iron ore prices extended Thursday's gains.
Bucking the trend, gold stocks .AXGD dropped nearly 2% to their lowest since Sept. 19 at close, with the bullion ending the week lower, as investors preferred the safety of the dollar in the wake of political uncertainties in the United States.
Across the Tasman sea, New Zealand's benchmark S&P/NZX 50 index .NZ50 edged up 0.1%, or 13.7 points, to end at 10,836.50 boosted by energy and financial stocks.
The index also logged in a weekly gain, closing about 0.1% higher, after two straight weeks in the red.