BREGA, Libya  From the feeble cover of sand dunes, under assault from a warplane overhead and heavy artillery from a hill, rebels in this strategic oil city repelled an attack by hundreds of Col. Muammar el-Qaddafi’s fighters on Wednesday. The daylong battle was the first major incursion by the colonel’s forces in the rebel-held east of the country since the Libyan uprising began.

The battle began at daybreak, when government fighters stormed the airport and the area around the city’s oil refinery. By the early afternoon, hundreds of men from this city, wielding Kalashnikov rifles and knives  joined by confederates from neighboring cities with heavier artillery  fought Colonel Qaddafi’s men, who were backed by air power and mortars.

But as night fell, the government fighters were on the run and the rebels were celebrating in Brega and all along the road north to Benghazi, the seat of rebel power, where fireworks lighted up the sky.

The attack seemed to spearhead a broader effort by the government of Colonel Qaddafi to reassert control over strategic oil assets in the eastern part of the country, which have been seized by rebel forces. And what appeared to be a victory by the rebels continued a string of recent successes in beating back those attacks, as they did in the western city of Zawiyah earlier this week. But the rebels have not been able to shake the colonel’s hold on power.