They were originally built with Mirrlees JVS12T 1,250 bhp (930 kW) and 1,365 bhp (1,018 kW) engines and Brush electrical equipment, but the engines were not successful and in 1964 a programme of works commenced to re-engine the fleet with the English Electric 12SVT engines as used in the Class 37 de-rated to 1,470 bhp (1,100 kW) which was the maximum the electrical system could accept.

The locomotives were originally known as Class 30 under TOPS, with re-engined examples joining Class 31. The class was originally intended for service on the Eastern Region, but gradually became common in both the Western and London Midland regions too.

These first 20 locomotives, originally numbered D5500-D5519, were always easily recognisable as they did not have the headcode box mounted on the roof above the cab, leading to the nickname "Skinheads". They were also nicknamed "Gurglers" from the noise of their engines, and "Toffee Apples" from the shape of the control key which had to be taken from cab to cab when changing ends. These pilot scheme locomotives were non-standard in having Electro-Magnetic Multiple-Working control equipment, and were limited to 80 mph (130 km/h). After being involved in a serious collision D5518 was rebuilt as a standard locomotive, with indicator boxes, blue star coupling code, and 90 mph (140 km/h) gearing.

They were allocated to East Anglian sheds throughout their service, ending up allocated to Stratford and latterly sporting that depot's trademark silver roof. Upon withdrawal four locomotives were converted at Stratford into train pre-heating units. Locomotives 31013, 31002, 31014 and 31008 were renumbered ADB968013 to ADB968016 in the order given;[2][3] ADB968014 was allocated to Bounds Green depot on the Great Northern main line and ADB968015 was based at Great Yarmouth, while the remaining two were allocated to Stratford.

The first few locos externally had much in common with the original 31/0s as they lacked the roof mounted headcode box, and were also limited to 80 mph (130 km/h), but were otherwise the same as subsequent locos. The whole sub-class had steam heating boilers fitted, had the Blue Star Electro-Pneumatic multiple-working controls as found on many other BR classes. The Class 31/1s could be found on a variety of secondary and relief passenger duties as well as parcels and freight traffic. While used in East Anglia, with locos allocated to Stratford and March depots, they were found throughout the Eastern Region of BR with Finsbury Park sporting a large allocation along with the depots at Tinsley, Immingham and Thornaby. Locos were also allocated to Bristol Bath Road and Old Oak Common on the Western Region, where they could be found working passenger trains as far west as Barnstaple and Paignton.[4] In the early 1980s Healey Mills and Bescot on the Midland Region also gained an allocation as replacements for Class 25s.

The Class 31/4s, numbered from 31400 to 31469, were conversions of 31/1s to which ETH was fitted. They had an ETH index of 66, equivalent to 330 kW, which was sufficient to power trains of up to eleven Mk 3 carriages, in order to allow them to power long trains, whose service run would be worked by a larger locomotive, between depot and terminus, although in actual passenger service loads rarely exceeded four or five carriages. 330 kW accounted for about a third of the total electrical power output. The early conversions tapped off the main generator such that none of the ETH power was available for traction even if the ETH was not being used. The traction power output of some of the 31/4 subclass was therefore limited to a maximum of two-thirds of that of the non-ETH variants, this did not help the performance of an already somewhat underpowered locomotive, and late running of these 31/4-hauled services sometimes happened. Later conversions allowed unused ETH power to be used for traction.

On 2 January 1976, locomotive 31 241 was hauling a parcels train when a light engine ran into its rear. Time interval working was in force at the time.[5]

On 25 February 1979, locomovive 31 421 was hauling an engineering train that was working under a possession between Fratton and Hilsea, Hampshire. The adjacent line was open to traffic. A crane in the engineering train was foul of the other line when it was struck by a passing passenger train. One person was killed and nine were injured.[6]

On 9 March 1986, locomotive No. 31 436 was hauling a passenger train that was in a head-on collision with two light engines at Chinley, Derbyshire due to a signalman's error. One person was killed. Lack of training and a power cut were contributory factors.[7]

On 20 February 1987, a freight train ran away and was derailed by trap points at North Junction, Chinley. Locomotive No. 31 440 was hauling a train that collided with the wreckage.[8]

On 28 October 1988 two unmanned Class 31 locos (31 202 and 31 226), presumably with brakes not fully applied, rolled off together along a short siding near Cricklewood. After demolishing the buffer stop they ran down the embankment on to the North Circular road, although no-one was hurt. The second loco of the pair landed on the roof of the leading one, remaining precariously balanced. They were both withdrawn after the incident.[9]

Before the introduction of Class 66, EWS took control of the class 31s from the Mainline Freight and Trainload Freight companies. 31466 was repainted into EWS colours for the Toton TMD open day in May 1998 and soon became the only one of the class to be in traffic running in the EWS colours. 31255 also received EWS colours but never ran on the main line and spent its life at Toton until preservation. In their final days of EWS ownership, 31110 (scrapped at TJ Thompson's, Stockton in April 2007) was repainted into BR green in the summer of 1999 and featured its original number D5528 to mark the end of their working lives with EWS and worked the last EWS class 31 hauled railtour. The final four EWS locomotives were withdrawn in February 2001. The two EWS liveried locos are now preserved.

In 1998, FM Rail (then known as Fragonset Railways) purchased four redundant Class 31 locomotives from EWS. The first of these, no. 31452, was quickly repaired and repainted in a new black livery with a red mid-body band. It was quickly followed by nos. 31459 and 31468. Several more locomotives were also purchased, and in 1999, the first of two modified Class 31/6 locomotives re-entered traffic. The Class 31/6 31601 & 31602 subclass is essentially a modified Class 31/1 locomotive with through electric-train heating wiring. This enables a Class 31/4 and Class 31/6 to work in multiple and still heat the train, even if the no-heat Class 31/6 is attached to the carriages.

By this time, the Fragonset Class 31 fleet had expanded considerably to include three Class 31/1, three Class 31/4 and two Class 31/6 locomotives. Regular work at this time included use hauling Class 317electric multiple units from WAGN's Hornsey depot to Bedford for use with Thameslink. As units were still maintained at Hornsey, this meant regular workings between the two depots to swap units when maintenance was due.

Network Rail operates a fleet of three Class 31/1 locomotive, nos. 31105/233/285, and one Class 31/4 locomotive,31465 to haul test trains around the network. The locomotives were purchased from Fragonset, and overhauled at their Derby workshops. They have been repainted in Network Rail's new all-over yellow livery.

Prior to operating its own locomotives, Network Rail's predecessor, Railtrack, had hired two Class 31 locomotives from Fragonset. These two locomotives, nos. 31190 and 31601, were repainted in Railtrack's blue and lime green livery. With the overhaul and entry into service of Network Rail's own locomotives, these two engines were returned to Fragonset. They are now owned and operated by British American Railway Services, based at Washwood Heath in Birmingham.

Around 26 locomotives have been purchased (and preserved) for use on heritage railways around the UK. Of note are the first built, no. 31018, and the last built, no. 31327. There were a further seven, which have subsequently been scrapped.

31018, at the National Railway Museum in York, on 3 June 2004. This was the first locomotive of the Class to be built in 1957. It was withdrawn from service in 1976. It currently carries BR Blue livery. Note the absence of over-window head code panel, which were only omitted from the first few locomotives.

31271Stratford 1840-2001, pictured on 3 June 2004 at the York Railfest held to celebrate the 200th anniversary of railways. The locomotive is preserved at the Midland Railway - Butterley. It carries Trainload Construction livery, and was named to commemorate the former locomotive depot at Stratford.

Number 31107, seen at RVE Derby, was the locomotive used in the Top Gear crash

On 21 August 2006, Network Rail and the BBC Television programme Top Gear staged and filmed a crash between a Class 31 locomotive (31107) and a family car in order to promote rail safety. The off-limits event was the first of its type for 10 years and took place at Hibaldstowlevel crossing near Scawby in Lincolnshire, where the B1206 road crosses the Barnetby–Gainsborough railway line.

Two Class 31 locomotives and a parked Renault Espace were used during the crash. Network Rail's 31233 was used to propel 31107 up to a speed of 80 mph (130 km/h). The rear locomotive slowed down to a stop and 31107 continued to coast at a speed of 70–80 miles per hour into the road vehicle parked across the eastbound 'up' line.

For the crash, locomotive 31107 received a special black livery with the slogan "Level crossings — Don't run the risk" along the side in white lettering. The final 5 minute segment was originally scheduled for 4 February 2007 but was rescheduled, apparently due to a fatal crossing crash at Dingwall two days earlier.[10][11] It was eventually aired on BBC Two on 25 February 2007, shortly after the Cumbria derailment. A repeat of the programme was pulled following a further level-crossing accident.[12][13][14][15]

Class 31 no. 31108 appeared on 1 November 2010 in the BBC soap opera EastEnders. The scene shows Janine Butcher nearly being hit by a train on a level crossing, and was filmed at the Nene Valley Railway.[citation needed]