The origins of the present-day community in the Llynfi Valley date from the late 1820s when the area's considerable coal and iron ore resources were developed on an industrial scale for the first time. In 1828 a 15-mile horse-drawn railway was completed between Porthcawl and Garnlwyd in the Llynfi Valley. This was the Dyffryn Llynfi and Porthcawl Railway (DLPR); it was extended to the Coegnant district near the head of the valley in 1830. The railway opened up the district and led to the formation of an iron company which began building a works on Maesteg Uchaf Farm, near the site of the present-day town centre, in 1826. The company took its name from the farm, and by 1831 two furnaces were in blast and the first rows of workers' housing had been completed near the Maesteg Ironworks. At about the same time one of the first zinc smelters in Wales was set up on Coegnant Farm near the northern terminus of the DLPR.