A BOUT of optimism returned to the sharemarket yesterday, with the first positive close in four days, after a series of opinion polls suggested a pro-austerity government might soon be elected to power in Greece.

The S&P/ASX 200 Index gained 38.8 points, or 1 per cent, to 4068.

The prospect that pro-bailout conservatives might soon be governing in Greece provided a catalyst for a ''risk-on'' trading day. Riskier sectors - resources, energy and financial stocks - performed strongly.

Fortescue Metals was the star performer, jumping 24¢, or 5.6 per cent, to $4.55, with help from an upgrade by Deutsche Bank. BHP Billiton gained 44¢, or 1.4 per cent, to $32.05 while Rio Tinto jumped 97¢, or 1.7 per cent, to $56.90.

Woodside Petroleum led the energy sector higher, finishing up 64¢, or 2 per cent, at $31.64.

National Australia Bank led the big four banks higher, firming 35¢ to $23.65, while Macquarie Group surged 69¢ to $26.52.

Defensive stocks weighed on the market, with telecoms, healthcare, utilities and consumer staples all struggling.

Consumer staples stocks Woolworths and Wesfarmers slipped more than 1.1 per cent, with Woolworths down 43¢ at $26.26 and Wesfarmers down 34¢ at $28.66.

Myer edged up 3¢ to $2 after its heavy falls last week.

Lonsec analyst Michael Heffernan said the market had taken its lead from a better performance by European markets on Friday.

''They don't seem to believe there is going to be

a catastrophe in the next couple of weeks, so I think we've taken a bit of heart from that,'' he said.

Qantas rose 4.5¢ to $1.50, despite Jetstar being taken to court for allegedly allowing cabin crew recruited from Thailand to be paid about half the rate of the budget airline's Australian staff.

Fairfax shares firmed 2¢ to 64.5¢ following news that mining magnate Gina Rinehart had lifted her stake in the company.

The dollar firmed slightly after last week's losses, closing at US98.74¢, up from US97.64¢ on Friday.

Royal Bank of Scotland senior currency strategist Greg Gibbs said the dollar had settled a little after speculative currency traders on the Chicago Mutual Exchange last week pushed it into a rare ''short'' position - meaning they believed the dollar would continue to lose value against the greenback.

''The last time you saw a short position was in 2008, and that suggests the market has basically got itself quite bearish on the Aussie and was due for some kind of correction, which we saw today.''

With AAP.