* Anti-aircraft gunfire and explosions heard near Benghazi
* Government set deadline for rebels to end oil blockade
* Nascent army takes on experienced militia
BENGHAZI, Libya, March 22 (Reuters) - Libyan troops fought with rebels occupying oil ports on Saturday after fighters attacked an army base where military reinforcements were preparing for an offensive to break the blockade, local residents said.
Anti-aircraft gunfire and explosions were heard late at night and again after dawn on Saturday in Ajdabiya, the hometown of rebel leader Ibrahim Jathran, near the main eastern city of Benghazi.
The central government in Tripoli gave Jathran a two-week deadline on March 12 to end a blockade of three oil ports or face a military assault.
Last Sunday, U.S. forces stormed a tanker that had made it as far as the eastern Mediterranean after loading crude at one of three ports Jahtran's men have occupied.
On Saturday morning, troops loyal to Jathran attacked an army camp which had been reinforced after the government issued its threat of a military offensive, residents said.
"You can hear heavy shooting at several places in Ajdabiya," said a resident. Casualties were reported on social media but Reuters was unable to get immediate confirmation from hospitals.
Jathran's movement could not be reached and there was no government comment.
State news agency LANA only ran a brief story late on Friday, with the army's chief of staff warning citizens not to approach any military installation.
The town is divided between Jathran supporters and those who fear his oil blockade will lead to state collapse.
The weak government in Tripoli is unable to control dozens of militias who helped oust former leader Muammar Gaddafi but then kept their weapons to grab power and oil.
Analysts say the nascent army, sill in training, will struggle against Jathran's forces which gained much experience in helping to overthrow Gaddafi during the NATO-backed uprising.
Jathran's movement says it seized three eastern oil ports to demand regional autonomy and a greater share of oil wealth. (Reporting by Ayman al-Warfalli; Writing by Ulf Laessing; Editing by Robin Pomeroy)