History is not on any president’s side in a midterm election. But there are three occasions since 1934 when a president’s political party actually gained seats in Congress.

Since 1862, the president’s party on average loses 32 House seats and more than two Senate seats in a midterm election. And in the 47 midterms since 1826, the president’s party lost seats in 41 of them, according to The Wall Street Journal.

Here’s a look at the three notable exceptions.

1. FDR’s Democratic Party in 1934

President Herbert Hoover, a Republican, presided over the Great Depression spurred by the 1929 stock market crash. In 1932, Democrat Franklin D. Roosevelt defeated Hoover in a landslide and went on to push his New Deal legislation.

Recovery wasn’t happening as quickly as promised. But, coming back from an economic crisis, the country gave FDR another nine House Democrats and another 10 Senate Democrats in the 1934 midterm elections to continue his New Deal agenda.

2. Clinton’s Impeachment Threat in 1998

More than six decades later, there was every reason to expect Democratic losses.

In 1998, President Bill Clinton was in the midst of fending off impeachment over an attempted coverup of his affair with White House intern Monica Lewinsky that involved allegations of perjury and obstruction of justice.

However, the public largely turned against House Republicans’ drive to impeach the Democratic president, and disapproved of the independent counsel’s investigation. The economy was also strong.

Democrats won five House seats and stayed even in the Senate. Republicans retained control of Congress. Hardly a watershed, this was a major disappointment to Republicans.

The Republican-controlled House still impeached Clinton for perjury and obstruction of justice. However, the Senate acquitted him, and he served out his second term.

3. Bush, the War President

President George W. Bush came into office in 2001 after a deadlocked election that would be determined by a Supreme Court ruling over Florida’s 25 electoral votes. The Republican president appeared vulnerable.

After Sen. Jim Jeffords of Vermont switched from Republican to independent, Democrats had control of the Senate. But the 9/11 terrorist attacks on the World Trade Center and the Pentagon put the country on a war footing and rallied the nation behind the new president.

In the 2002 midterm election, the GOP won six House seats and two Senate seats to retake the Senate majority and hold both chambers of Congress.