Steelworkers take a break at the Ilich iron and steel plant in the southern coastal town of Mariupol. Thomson Reuters The war is being fought just over the hills. Civilians have started to flee the city. But the men of the vast Ilyich iron and steel works in the Ukrainian port of Mariupol are still in place, pouring molten steel, running the rolling mill, and pledging to defend their factory and town from an onslaught by pro-Russian rebels.

Mariupol, a port of around half a million people, is the next big city in the path of advancing rebels, who opened a new front and scattered Ukrainian troops along the coast of the Azov Sea last week with what Kiev says is help from the Russian army.

Moscow denies sending troops and tanks to help the rebels, despite what Kiev and its Western allies say is overwhelming evidence.

The port is a strategic link between the rebel-held regional capital Donetsk to the north, the sea, and the land route to the Crimean peninsula, which Russia annexed in March.

Pro-Russian separatists took over buildings in the city in April when they rose up against Kiev. But metalworkers took to the streets in June, joining police patrols to help sweep the rebels out, the start of a government fightback that had continued until the rebel advance last week.

"We got organized, we resisted, and we won," said smelter production manager Alexander Ilarionov, adding that most workers were ready to defend the plant and the city once again.

The plant is owned by Metinvest, the industrial conglomerate of Rinat Akhmetov, by far Ukraine's richest man, whose decision to send his workers to help chase away rebels was one of the first important signs that Kiev had a chance of reasserting control over rebel territory.

Most people here identify themselves as ethnic Ukrainians, although they speak Russian as their native language. Residents now seem firmly with Kiev — although the opinions heard on the streets in eastern Ukraine have been known to depend on which side's armed men are in control.

The Ilyich steelworks is a 15-kilometer (10 mile) maze of production facilities, rusty pipes, roads, and railway tracks with a workforce of 27,000, and keeping it going in wartime is no small feat.

Other Metinvest plants in the Donbas region have been shut. On Aug. 18 Metinvest announced it was halting production at three plants after artillery fire destroyed their power supply. It also stopped production at its main coke plant Avdiyivka, which produces 40 percent of Ukraine's coke.

The Ilyich plant continued working, more or less unscathed though hit by shortages of materials. But since the fall last week of Novoazovsk, about 40 km (25 miles) up the coast, to a separatist force that Kiev says was backed by a Russian armored column, the frontline has come ever closer.

Two days ago, a coastguard boat was sunk off the coast just 30 km (19 miles) away.

Ukrainian troops and residents from Mariupol have been digging trenches and setting up gun emplacements, reinforcing defenses for a Russian-backed attack. Meanwhile, the steelmen take pride in keeping the plant running.

"We are maintaining production, while people are shooting at each other only kilometers away," said Ilarionov. "One shell, only one explosion on a high-voltage power line and that's it. It will all be brought to a standstill."

The plant is an economic lifeline for the entire region. Metinvest is Ukraine's largest steelmaker, and in 2013 the Ilyich plant accounted for 41 percent of the company's total crude steel production.

Metinvest stopped accepting new orders from buyers in May because of the crisis and halted its output at plants including Yenakiyieve Steel, a leading manufacturer of square billets and the Khartsyzsk pipe plant, one of Europe's top producers of large-diameter pipe.

The rolling mill that forms part of the Ilyich plant has also halved its capacity because of the lack of raw materials and coke, said Dmitry Mezhenko, a deputy director of the plant.

"We are still exporting to Russia and Croatia as the sea port is operational," he said. "We need work and security. There's a risk of disruption of production, and any loss (of production) would endanger Mariupol and the company."

Ilya, a plant worker, said he planned to evacuate his family if the city comes under attack but would stay himself to fight for the factory.

"This is our gem. The Russians would like to either seize it or render it unusable, so we will prevent them."

(Writing by Richard Balmforth; Editing by Peter Graff)