LUDWIGSHAFEN, Germany — In the 1860s an entrepreneur named Friedrich Engelhorn started a firm here to produce dyes for Europe’s booming textile industry. Almost 150 years later, that company, Badische Anilin & Soda Fabrik — or BASF — is the world’s largest maker of chemicals.

Despite its growth into a global company, BASF has remained an integral part of the industrial base that has helped Germany grow into Europe’s largest economy. And Ludwigshafen remains the company’s hometown. The BASF site, spread over four square miles along the Rhine River, resembles a small city, with 33,000 employees working in 2,000 buildings, crisscrossed by roads and railways.

Lately, though, BASF has been investing more of its money and management energy outside Germany, especially in the United States. And the company’s reasons for doing that help illustrate why the German industrial economy has been losing momentum — and why Germany risks tipping back into recession.

BASF executives say that German and European Union policies toward industry, particularly when it comes to energy, are forcing big companies to look elsewhere as they seek to expand.