US President Donald Trump has said he is ready to work with Democrats after they won control of the House of Representatives in mid-term elections.
But during a testy news conference, he vowed to adopt a "warlike posture" if Democrats investigated him.
The Republican president also clashed repeatedly with reporters at the White House, ordering them to be quiet.
Top Democrat Nancy Pelosi offered to work with Mr Trump, but pledged due oversight of his administration.
Has bipartisanship broken out?
In Wednesday's news conference, Mr Trump extended an olive branch to Democrats, proposing both parties work together on joint legislative priorities.
He suggested they could co-operate on issues such as infrastructure, trade and health.
But he said that if Democrats start serving legal writs against him, Republicans would retaliate in kind.
Ms Pelosi, who is favoured to pick up the House speaker's gavel, promised her party would serve as a counterweight to the White House.
At her news conference, she said Democrats would seek compromise with the president, but "must stand our ground".
Democrats will now control lower chamber panels that can investigate Mr Trump's business affairs, including tax returns, while thwarting his legislative agenda.
What else did Trump say?
Mr Trump hailed "tremendous success" and an "incredible day" for his party in Tuesday's elections.
He took credit for Republicans having "defied history" by consolidating their grip on the Senate.
The president also mocked Republicans who did not "embrace" him on the campaign trail, and went on to lose their election races.
"They did very poorly," Mr Trump told reporters. "I'm not sure that I should be happy or sad but I feel just fine about it."
In ill-tempered exchanges, he called CNN correspondent Jim Acosta "a rude, terrible person" and told an NBC reporter: "I'm not a big fan of yours either."
The president became irate when questioned about his characterisation of Central American migrants heading towards the US as an "invasion".
Mr Trump told a black reporter who asked whether his self-professed nationalism would embolden white nationalists that it was "such a racist question".
Following the press conference, he announced in a tweet he had fired Attorney General Jeff Sessions.
Bipartisanship - with conditions
Analysis by Anthony Zurcher, BBC News
Donald Trump came to the East Room of the White House with olive branch in hand, but it sometimes seemed like his fingers were crossed behind his back.
He told the nation he would love to work with Democrats - that it might, in fact, be a good thing that they won control of the House of Representatives - but he refused to back away from any of his divisive campaign rhetoric.
Previous presidents who have suffered mid-term setbacks have professed humility and said they learned valuable lessons. Bill Clinton and Barack Obama, whose parties lost the House in the middle of their first terms, used the defeats to recalibrate for successful re-election campaigns.
Mr Trump entertains no such thoughts, instead calling Tuesday night's results "very close to complete victory". The president may say he wants "unity and peace and love" - but it's clear it will have to be on his terms.
What's the election outcome?
The Democrats gained more than the 23 seats they needed for a majority in the 435-seat House of Representatives.
But Republicans are on course to increase their representation from 51 to 54 in the 100-seat Senate.
That will allow Mr Trump's party greater leeway over judicial and executive appointments.
In the upper chamber, they captured Democratic seats in Indiana, Missouri and North Dakota, won a marquee battle in Texas, and currently look set to win a tight Florida race.
Republican challenger Rick Scott won 50.2% of the vote against incumbent Democratic senator Bill Nelson. Under Florida law an automatic recount is triggered when a final margin is less than 0.5%, and while an initial count will not be complete until Saturday it looks set to fall within that margin.
Republican senatorial candidate Martha McSally is also ahead in Arizona, with nearly all precincts reporting.
Democrats held on to vulnerable seats in Montana, New Jersey and West Virginia and ousted a Republican incumbent in Nevada, but it was cold comfort.
In the 36 governors' races, Republicans won an ugly battle in Florida and appeared on the cusp of victory in Georgia.
Democrats captured gubernatorial mansions in Michigan, Illinois, Kansas and Wisconsin, where former Republican presidential contender Scott Walker was beaten.
More on the mid-terms:
Who are the new faces in Congress?
Female candidates fared particularly well in an election cycle that had been billed as the Year of the Woman.
Two 29-year-old Democrats - Alexandria Ocasio-Cortez and Abby Finkenauer - are due to be the youngest women ever to win House seats.
Ilhan Omar and Rashida Tlaib are the first Muslim women and Sharice Davids and Debra Haaland the first Native American women to be elected to Congress. All are Democrats.
Ayanna Pressley was elected as Massachusetts' first black congresswoman.