The incident happened at Irvine Beach Park in Ayrshire on Saturday afternoon.
Ardrossan Coastguard Rescue Team said they were at the beach when they spotted the girl being carried out to sea on an inflatable unicorn, which quickly ended up “some distance” from the shore.
Her father headed into the water and began swimming to try and reach her.
The team contacted the coastguard operations centre in Belfast to summon extra resources, while the Troon Lifeboat was also launched.
“As the team were preparing for an immediate snatch rescue, the person (the father) had reached the young girl who was now in the water with the inflatable having blown away out to sea, and was making attempts to get back to shore,” the coastguard said in an update on Facebook.
A rescuer in full water rescue kit went into the sea to help the two get back to the shore safely.
The casualties, who had swallowed sea water during the drama, were given first aid, checked over by paramedics and taken to hospital as a precaution.
Kevin Paterson, station officer for the Ardrossan Coastguard Rescue Team, said: “This was an incredibly lucky escape for the young girl and her father after a sunny day at the beach quickly turned into an emergency.”
The team is warning people about the dangers of using inflatables in the sea.
“These inflatables should only be used in swimming pools where there’s no risk of being blown out to sea and there’s lifeguards on duty,” added Mr Paterson.
The team was at the beach as part of the Ayrshire Safer Shores initiative.
Meanwhile, Scotland’s blistering Bank Holiday weather shows no sign of cooling down, with top temperatures stretching right into June.
With some spots hitting 25C (77F) today the country is fully 10C (50F) warmer than you would expect for the end of this month.
We have - fortunately - become stuck between the Jetstream circulating north of Iceland and thunderstorms that are creeping in from the near continent.
As a result, the west of Scotland in particular will enjoy sunny spells and next to no rain right through beyond next weekend.