[pascal]
Ray.Dir := Normalise(VecSub(Pos, cam.Origin));
Col:= Raytrace(Ray, 0 , HitPrim, Ch);
if (LastPrim <> Ch) or (LastPrims[Rx] <> Ch) then //If last hit primitive is different to this one
begin
For SubX := -1 to 1 do
for SubY := -1 to 1 do
if (SubX <> 0) or (SubY <> 0) then //Already sampled the center point.
begin
D := Pos;
D := VecAdd(D,VecMult(A, SubX*0.5));
D := VecAdd(D,VecMult(B, SubY*0.5)); //Adds a slight offset in 3D space
Ray.Dir := Normalise(VecSub(D, cam.Origin));
AccCol:= Raytrace(Ray, 0 , HitPrim, Ch);
Col := VecAdd(Col, AccCol); //Add subsample to accumulator color



end;
P^ := Rgb(round(Col[0]*255/9), round(Col[1]*255/9), round(Col[2]*255/9)); //average all 9 subsamples.

end
else
P^ := Rgb(round(Col[0]*255), round(Col[1]*255), round(Col[2]*255));
[/pascal]

Basically you just send off 9 rays for 1 pixel. Each with a slight offset.
The trick comes when you record the last hit primitive, because you dont need to antialias pixels inside primitives, only on the boundaries between primitives.