A man has attempted to set himself on fire outside the Sydney offices of the Department of Immigration and Border Protection.

The 37-year-old man, believed to be of Iranian background, went to the office in Lee Street, Haymarket, at 1.30pm on Friday.

He then doused himself in petrol, police say, and threatened to self-immolate.

Police attempted to negotiate with the man for about 10 minutes, however the negotiation broke down and he set himself on fire.

Detective Superintendent David Donohue from Sydney City Local Area Command said nearby officers then acted to spray him with fire extinguishers.