It seems that regulations and opinions on this are varied. It depends (very strongly) on the denomination and what they believe.
I'll put this here for later reference:
1 Corinthians 11:27-28 (NIV)
27 So then, whoever eats the bread or drinks the cup of the Lord in an
unworthy manner will be guilty of sinning against the body and blood
of the Lord. 28 Everyone ought to examine themselves before they eat
of the bread and drink from the cup.
One belief is that the communion should be something solely for people who are saved, committed Christians.
As The Rev. Gerald Schrankler said in this thread:
If we invite non-baptized, non-Christians, to communion we degrade it from a celebration of our redemption by Christ's death and resurrection to a fellowship snack.
The background idea behind this is that Christians who are not baptized are not saved. Since they're not saved, they should not be able to partake of the communion and are in violation of 1 Corinthians 11:27.
Another Protestant View
John Wesley, however, believed that communion was a "means of grace" (source). Therefore, it shouldn't be withheld from anyone--believers or non-believers.
The idea here is that if someone wants to come to communion, we should not prevent them. It may very well be the means that leads to their salvation! Clearly that's not something we would want to withhold.
Catholics actually allow others to take part in the Holy Communion, with tight restrictions.
Guidelines for the Reception of Communion
...A person who is conscious of grave sin is not to receive the Body and Blood of the Lord without prior sacramental confession except for a grave reason where there is no opportunity for confession....
For Other Christians
...Members of the Orthodox Churches, the Assyrian Church of the East, and the Polish National Catholic Church are urged to respect the discipline of their own Churches. According to Roman Catholic discipline, the Code of Canon Law does not object to the reception of communion by Christians of these Churches.
...While we cannot admit them to Holy Communion, we ask them to offer their prayers for the peace and the unity of the human family.
Link to article
Ultimately, it seems that there are very widely dispersed opinions on this matter. The biblical basis as you asked, is 1 Corinthians 11:27-28. However, the interpretation of that verse has lead to varied regulations.