A flat-four or horizontally opposed-4 is a flat engine with four cylinders arranged horizontally in two banks of two cylinders on each side of a central crankcase.

The pistons are usually mounted on the crankshaft such that opposing pistons move back and forth in opposite directions at the same time, somewhat like boxing competitors punching their gloves together before a fight, which has led to it being referred to as a boxer engine.

The configuration results in inherently good balance of the reciprocating parts, a low centre of gravity, and a very short engine length. The layout also lends itself to efficient air cooling. However, it is an expensive design to manufacture, and somewhat too wide for compact automobile engine compartments, which makes it more suitable for cruising motorcycles and aircraft than ordinary passenger cars.

This is no longer a common configuration, but some brands of automobile use such engines and it is a common configuration for smaller aircraft engines such as made by Lycoming, Continental and Rotax. Although they are somewhat superior to straight-4s in terms of vibrations, they have largely fallen out of favor because they have two cylinder banks thus requiring twice as many camshafts as a straight-4 (if an OHC rather than OHV or F-head configuration is used) while the crankshaft is as complex to manufacture. The low centre of gravity of the engine is an advantage. The shape of the engine suits it better for mid engine or rear engine designs. With a rear engine layout it allows a low-tail body while in front engine designs the width of the engine interferes with the ability of the front wheels to steer. The latter problem has not stopped Subaru from using it in its all-wheel drive cars, where the difficulty of fitting the short engine between the front wheels ahead of the front axle is compensated for by the ease of locating the transmission and four-wheel drive mechanisms behind it, between the front and rear axles.

The open and exposed design of the engine allows air cooling as well as water cooling, and in air-cooled applications fins are often cast into the external cylinder block walls to improve the engine cooling.

Balance and smoothness

Boxer engines are better balanced than other engine types in 4-cylinder configurations. The more common inline-4 configuration suffers from an engine balance problem caused by the fact that the pistons travel faster on the top half of the crankshaft rotation than the bottom half, which causes the engine to vibrate up and down twice per crankshaft revolution. This problem becomes worse with increased engine size and power so inline-4s larger than 2.0 L usually have balance shafts and ones over 3.0 L are seldom used in passenger cars. However, the flat-4 does have a less serious secondary imbalance that causes it to rotate back and forth around a vertical axis twice per crankshaft revolution. This is because the cylinders cannot be directly opposed, but must be offset somewhat so the piston connecting rods can be on separate crank pins, which results in the forces being slightly off-centre. The vibration is usually not serious enough to require balance shafts.

In addition, four-stroke cycle flat-4s have a problem common to all four-cylinder engines: the power strokes do not overlap. With a piston starting its power strokes every 180 degrees of crankshaft rotation, and the crank throws 180 degrees apart, all the pistons must come to complete stop and reverse before the next one can start its power stroke. This results in a gap between power strokes and a pulsating delivery of power to the flywheel. By contrast, in engines with more cylinders the power strokes overlap: the next piston starts its power stroke before the previous one has finished, and the delivery of power is much smoother.

As a result of the relatively high manufacturing costs of the flat-4 compared to the inline-4, most manufacturers now choose the inline-4 engine for economy models and have moved to inline-5 or V6 engines for models requiring more power. These engines also suffer from dynamic imbalance problems, but with modern computer-aided design techniques, the problems can be overcome with a variety of complex crankshaft, balance shaft, and engine mounting designs. Luxury performance car manufacturers prefer to use the inline-6, flat-6, or V8 configurations because these designs are in intrinsic primary and secondary balance and thus are much smoother than the flat-4, particularly at high power outputs.

Automobile use

Tatra introduced an air-cooled flat four engine in the 1926 Tatra 30, followed by the T52 of 1930, T54 of 1931, T57 in 1931, and T75 in 1933, all with air-cooled flat fours of varying displacement. The 1936 T97 model pioneered the rear-engined, air-cooled flat-four, backbone chassis layout, later copied by the Volkswagen KdF-Wagen.

Jowetts before the Second World War were best known for their flat twin engines, but they made a flat four for the Jason and 10 hp models in the 1930s. Post-war Gerald Palmer designed Javelin saloon and Jupiter sports models used a totally different design of flat four. Alec Issigonis originally designed the Morris Minor for a flat four, but cost constraints meant it was never used.

Volkswagen used air-cooled flat-4s extensively in their early days, in the VW Beetle and most early VW designs. Porsche also used the VW engine in the early Porsche 356. This engine was replaced by a Porsche designed flat-4 in the late 356s and the 912. The 914 that replaced the 912 was built in partnership with VW using a VW engine.

The Goliath 1100 appeared at the Geneva Motor Show in March 1957, with a water-cooled 1100 cc flat four driving the front wheels. In 1958 the name was changed to the Hansa 1100, and this car was produced through 1961.

VW used a water-cooled flat-4 Wasserboxer in the later third-generation Type 2 until 1991.

Citroën used an air-cooled flat-4 on the Ami Super, GS, GSA and Axel.

Water-cooled Alfa Romeo flat-4 was introduced in 1971 on the Alfa Romeo Alfasud. That engine was later used on the Alfa Romeo Arna, the Alfa Romeo 33, the Alfa Romeo Sprint and the Alfa Romeo 145/146.

Lancia used a water-cooled flat-4 on the Lancia Flavia and high-end Lancia Gamma.

Subaru produces a water-cooled front-mounted flat-4 engine marketed as H-4, by which they mean Horizontal rather than the H cross-section normally meant by H engine. Subaru has created a number of engines, starting with the EA series introduced in 1966, progressing towards the currently used EJ series, which is wide but very short and light, and is mounted ahead of the front axle with the transmission behind. With this layout, the gearbox can remain very similar to common transmissions in both design and weight without the need for a bulky and inefficient transfer case. Although it is more expensive than a straight-4, it allows Subaru to build an all-wheel drive vehicle at little extra cost over two-wheel drive.

A 2.0 L Flat-four engine with 200 hp having GDI was developed by a joint venture by Subaru (FA20) and Toyota (4U-GSE) for the two-door coupe Toyota 86.

Porsche announced in 2012 that they are developing a new 2.5-litre flat-4, their first flat-four since the 1970s Porsche 914.