Yes, the Queen has this power, or a variant on it.
Strictly speaking, after a general election, or when a prime minister resigns, the Queen sends for someone and invites them to form a government. They cannot form a government without the support of a majority in the House of Commons, so the Queen always sends for the leader of the party with a majority in the House.
The UK’s bizarre electoral system makes it very unlikely that no party will have a majority, but it can happen. If no party has a majority, the larger parties will try to do a deal for support with a smaller party or parties which holds the balance of power. If they succeed, she sends for the leader of that party.
If no party has a majority, and no deal can be struck, the outgoing prime minister will usually advise her to dissolve parliament and hold a general election. But if there has just been a general election, this might be pointless - there is no reason to expect a clearer result. In these conditions (and note that these conditions have not been satisifiedi in modern times) then she has a discretion as to who to send for. She will (presumably) send for the person who she thinks has the best chance of forming a government. The very fact that she has sent for him gives him a slight advantage in trying to put together the necessary support. He would become prime minister, and remain prime minister until such time as he lost a vote in the House of Commons. Those smaller parties which are not committed to supporting him would hesitate to have him lose a vote, since this might be electorally unpopular (the electorate doesn’t like frequent elections). Also, for a time he will probably try to bring forward only such measures as he thinks are likely to command cross-party support.
This would not be a very stable arrangement, but it would keep things going for a while as efforts to do a firm deal on government support continued. If all else failed, it would allow some months to pass before another general election, and would increase the chances that the next election would produce a more definitive result.